Click to See Complete Forum and Search --> : How to dynamically set value of a checkbox


emmanuellamy
05-11-2003, 02:48 AM
Hi everybody,

I am trying to set the "state" of a checkbox, based on the value of another checkbox.

I tried an approach like this:

var checkbox1=this.getField("checkbox1ID");
var checkbox2=this.getField("checkbox2ID");

if (checkbox1.value==true)
{
checkbox2.value=false;
}

if (checkbox1.value==false)
(
checkbox2.value=true;
)

Indeed, it did not work. I am confused about how to reference the state "checked" or "unchecked" of a checkbox. Is the value of a "checked" checkbox is internally set to true, and the "unchecked" set to false? Answer to that question may help me move forward. Any help is welcome. Anticipated thanks.

Emmanuel

Nevermore
05-11-2003, 07:08 AM
checkboxname.checked=true; will check a box. To change it when another box is checked, you could use onclick or onchange.

emmanuellamy
05-11-2003, 03:10 PM
Thanks a lot, guys!