Web Analytics Made Easy -
StatCounter Tags with same ID - CodingForum

Announcement

Collapse
No announcement yet.

Tags with same ID

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tags with same ID

    Hi,

    If I were to create tags with the same ID name and would like to dynamically change the contents of each tag with that name, how can this be done in IE and NS4+ ?


    getElementById is used to refernece one tag.
    getElementsByName is used in IE ONLY.

    I don't know about NS...


    Can you help?

  • #2
    I don't know if this is what you meant, but it's as close as I got:

    <SPAN ID="d0"></SPAN>
    <SPAN ID="d1"></SPAN>
    <SPAN ID="d2"></SPAN>
    <SCRIPT>
    var d=[d0,d1,d2]
    function bomb(){
    setTimeout("d[0].innerText='A'",1000)
    setTimeout("d[1].innerText='B'",2000)
    setTimeout("d[2].innerText='C'",3000)
    }
    bomb()
    </SCRIPT>

    I tried using two tags with the same name, but it didn't process at all in IE, Sorry

    Guardian

    Comment


    • #3
      If W3C compliance means anything, or if simply having a valid document means anything, the id attribute must be a unique value.

      NS6 supports document.getElementsByName fyi.
      jasonkarldavis.com

      Comment


      • #4
        Originally posted by jkd
        If W3C compliance means anything, or if simply having a valid document means anything, the id attribute must be a unique value.

        NS6 supports document.getElementsByName fyi.

        Thank You!

        I was thinking that by using the same name I can effectively create an array of the tag by which I can then quickly enumerate to do what ever... (I guess I should have been thinking of Name instead)

        I couldn't find that NS6 supported anything other than getElementById... (I'll give it a try)

        ... I'm unsure about NS4-5 then ...

        Comment


        • #5
          Mozilla (and all Mozilla based browsers like Netscape) support these three functions for finding nodes:
          getElementById
          getElementsByName
          getElementsByTagName
          For more info on these functions,see the Gecko DOM reference.

          By the way,NS5 doesn't exist.It jumped from NS4 to NS6.

          Comment


          • #6
            On IE 6 (and therefore I assume also on IE5): typeofs:

            window.document.getElementsByName [typeof is-->object]
            window.document.getElementsByTagName [typeof is-->object]

            So it should work.

            ciao
            Alberto http://www.unitedscripters.com/

            Comment

            Working...
            X