Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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
    New Coder
    Join Date
    Jul 2002
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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.

  • #4
    New Coder
    Join Date
    Jul 2002
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ...


  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Netherlands
    Posts
    217
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    New Coder
    Join Date
    Jun 2002
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •