alix
Junior Member
Posts: 57
|
Post by alix on May 24, 2008 8:41:22 GMT -5
In the program below, I'm trying to use a JS function to change an image when you click on it, but it does not work...? (I have used images already in the Public directory, so it shoul run on any server)
'******************************************************************* ' ' Using a JS function to change an image on click ' '********************************************************************
img$="../public/runbutton.png" img2$="../public/savebutton.png"
html "<script type='text/JavaScript'>" html "var card = new Image();" html "card.src='"+img2$+"';" html "document.write(card.src);" html "function flip() { window.document.image.src=card.src; }" html "</script>"
html "<A HREF='JavaScript:flip()'>" html "<img src="""; img$;""" width=24 height=23>" html "</A>" wait
|
|
|
Post by Brent on May 25, 2008 1:07:57 GMT -5
Hello, "window.document.image" is undefined. You either need to give the IMG a unique ID, or if you can do without the hyperlink: <script type="text/javascript"> function flip(img) { img.src = 'imgname2.jpg'; } </script> ... <img src="imgname1.jpg" onclick="flip(this)">
|
|
alix
Junior Member
Posts: 57
|
Post by alix on May 25, 2008 4:15:39 GMT -5
Thank's so much Brent ! Your help is saving me lots of time... Here is the code that works in RB : '******************************************************************* ' ' Using a JS function to change an image on click ' '********************************************************************
img1$="../public/runbutton.png" img2$="../public/savebutton.png"
html "<script type='text/JavaScript'>" html "function flip(img) { var imgname='"+img2$+"'; img.src=imgname; }" html "</script>"
html "<img src="""; img1$;""" width=24 height=23 onclick='flip(this)'>"
wait
|
|