...

View Full Version : Tags with same ID



Claudio
07-04-2002, 06:43 AM
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?

Guardian23
07-04-2002, 07:53 AM
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

jkd
07-04-2002, 06:19 PM
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.

Claudio
07-04-2002, 06:43 PM
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 ...

:rolleyes: :thumbsup:

Bosko
07-04-2002, 06:47 PM
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 (http://mozilla.org/docs/dom/domref/dom_shortIX.html).

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

TrueLies
07-05-2002, 12:24 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum