Click to See Complete Forum and Search --> : Switching an img without a prebuilt function
sumyounguy
07-22-2003, 09:26 AM
Hi, I've got an images name attribute stored in string
myImg01='menu1item1img'
I've tried to use myImg01.src='yellow.gif';
but it has no effect...
is there any way i can change the img's source with its name in string format?
Khalid Ali
07-22-2003, 09:29 AM
You need to create an image object only then you can manipulate its src attribute...
var img = new Image();
img.src='whatever.gif"
sumyounguy
07-22-2003, 09:36 AM
yeah, but i'm pretty sure my code is set up in a way that i can't create an img like that, i need its name to be created from the string, not its filename, that part is easy
Khalid Ali
07-22-2003, 09:46 AM
Originally posted by sumyounguy
.......... that part is easy
Oh yeah...??
good luck..:D
sumyounguy
07-22-2003, 10:13 AM
Got it... just had to pass the string to a function as an argument, that fixed me...