View Full Version : radio button onClick not working, hopefully a simple fix?

11-11-2006, 10:49 PM
Hey I am trying to create a script that changes an image when a certain radio button is clicked, which should be pretty simple but I haven't written javascript in a long time so I am struggling... any help is appreciated, heres the code I've got:

<script language='JavaScript' type='text/javascript'>
function changeImage(newImage)
if document.images['img_name'].src = eval(newImage + ".src");
image1 = new Image();
image1.src = "images/pricing/avail_1.gif";

image2 = new Image();
image2.src = "images/pricing/avail_2.gif";

<input type="radio" onClick="changeImage('image1');" > </input> <br />
<input type="radio" onClick="changeImage('image2');" > </input> <br />

<img name="img_name" src="images/pricing/avail_1.gif">


11-11-2006, 11:04 PM
What is the "if" supposed to do in function changeImage()?


11-11-2006, 11:10 PM
oh, wow, it works now. thank you

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum