is****@hotmail.com (Lucanus) writes:
Can I have a document with three images with the same name, and
reference those images individually.
Why give them a name if they are all the same?
Give them different names instead, or preferably, different ids.
Why not
<img id="picture1" src="file1.jpg">
<img id="picture2" src="file2.jpg">
<img id="picture3" src="file3.jpg">
and
document.images['picture2'].src
ie:
<img name="picture" src="file1.jpg">
<img name="picture" src="file2.jpg">
<img name="picture" src="file3.jpg">
Would I be able to refer to 'document.picture[2].src' and retrieve
'file3.jpg'?
That depends on the browser, and most likely not.
What you can do, if those three images are the only ones on the page, is
document.images[2].src
In most browsers, you should be able to do:
document.images['picture'][2].src
I have tried this without success, and am hoping that you can educate
me on whether this is just poor syntax on my part,
Not syntax, but the access method. You write "document.<name of
element>". That is not a good way to access an element. Instead you
should go through either one of the collections (like
document.images['picture']) or use another method to access elements
(like document.getElementsByName("picture")).
On top of that is the problem of having more than one element with the
same name, which should generally be avoided outside of forms.
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'