Page 1 of 1

Multiple copies of One image

Posted: Fri Apr 16, 2004 2:18 pm
by llanitedave
Another javascript question, this one not related directly to PHP.

I'm trying to use javascript to place multiple copies of the same image on different areas of a page -- lets say a cluster of star icons, or something similar.

The reference I'm using is "JavaScript, the Complete Reference". I can't seem to find quite what I'm looking for there -- I don't want to have to define a separate ID for each image, because I don't necessarily know how many copies I'm going to make.

Has anyone here done something similar? Any hints?

Posted: Sat Apr 17, 2004 1:08 am
by MarK (CZ)
What about creating those images via element.innerHTML so you can add that id dynamically?

Posted: Sat Apr 17, 2004 12:23 pm
by llanitedave
Is that cross-browser?

Posted: Sat Apr 17, 2004 1:08 pm
by feyd
works in moz and ie, if that's what you are asking.

Posted: Sat Apr 17, 2004 2:32 pm
by MarK (CZ)
Or make that ID dynamically, but via PHP. That is cross-browser for sure ;)

Posted: Sat Apr 17, 2004 9:58 pm
by llanitedave
Well, can't use PHP for that particular project, since it's just supposed to be a javascript function. But ie and mozilla is good enough -- hopefully that means Safari too. I'll use it if I can't do it any other way. I was hoping to stick to a standards-only implementation, though.

OK -- what about the cloneNode method?