...

View Full Version : Has no properties



Mr J
02-08-2004, 05:48 PM
When I use the following in Mozilla I get the error

document.getElementById(rad_name) has no properties

Can someone please explain this and how to rectify it



<script language="JavaScript">
<!--
rad_on="radio_on.gif"

function rad_click(rad_name){
document.getElementById(rad_name).src = rad_on
}
// -->
</script>

<img onclick="rad_click(this.name)" src="radio_off.gif" name="mypic">

liorean
02-08-2004, 06:39 PM
Because the image had no id attribute matching the rad_name argument. Set an id on the image as well, or use document.images[rad_name] instead.

Garadon
02-08-2004, 06:41 PM
or to u could just send this to the function

then
rad_name.src=rad_on

should assign the picture to the send element

Mr J
02-08-2004, 08:00 PM
Thank you.

It's amazing, so simple yet so important

:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum