Click to See Complete Forum and Search --> : Change Image Source
bmccord
07-09-2003, 08:23 AM
I know it is probably simple, but I am new to the Java world. I have created a menu on my page and I want it to change the source of an image on my screen based on the link selected. Is there an image object or something i can use to do this?
Thanks in advance!
Brent
Khalid Ali
07-09-2003, 08:38 AM
yes, first you get he reference to the img element and then you change the src.Suppose you have an image aelement on page that has an id ittribute set
<img id="img_1" src="iiii.gif"/>
now you can get ref to it using
var img = document.getElementBYId("img_1");
//now you can change the src as required
img.setAttribute("src","222.gif");
bmccord
07-09-2003, 11:36 AM
Well, I am newer at this than I thought. I have attached the page I am using. I am not sure where to insert the lines of code you gave me. Can you help me out a little more
Thanks again in advance.
Brent