...

View Full Version : Addressing checkbox in order to uncheck it



gorilla1
10-17-2005, 10:29 PM
I am creating a script called by an onClick event for a checkbox. Under certain conditions, I want to reset the checkbox to unchecked in the function. The checkbox that has been checked is one of many checkboxes all with the same name (each has a unique id). To set the value of the check box back to unchecked, how can I address the checkbox? I have tried, for instance, this.checked=false, but this does not work.

G

Lerura
10-17-2005, 10:53 PM
document.getElementById('checkboxID').checked=false;

will do it.

if you have stored the checkboxname in variable i.e. function Uncheck(box) it should be:


document.getElementById(box).checked=false;

in the last example the checkbox's ID is called within the function onClick="Uncheck('checkboxID')"

gorilla1
10-17-2005, 11:53 PM
Awesome, thanks... I also got the following to work:

onClick="callFunction(this,etc);"

and in the script

callFunction(obj,etc) {
obj.checked=false;


G



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum