Multiple copies of One image

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
llanitedave
Forum Commoner
Posts: 78
Joined: Thu Jan 15, 2004 11:24 am
Location: Las Vegas, NV.

Multiple copies of One image

Post 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?
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post by MarK (CZ) »

What about creating those images via element.innerHTML so you can add that id dynamically?
User avatar
llanitedave
Forum Commoner
Posts: 78
Joined: Thu Jan 15, 2004 11:24 am
Location: Las Vegas, NV.

Post by llanitedave »

Is that cross-browser?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

works in moz and ie, if that's what you are asking.
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post by MarK (CZ) »

Or make that ID dynamically, but via PHP. That is cross-browser for sure ;)
User avatar
llanitedave
Forum Commoner
Posts: 78
Joined: Thu Jan 15, 2004 11:24 am
Location: Las Vegas, NV.

Post 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?
Post Reply