Forum Moderators: open

Message Too Old, No Replies

Disable/Enable form checkbox group

Using a radion button

         

aspdaddy

10:29 am on May 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is the code to disable the three checkboxes whenever the Impor raidio option is changed to 1 and enable them when its set to 0? Thanks.

<input type="radio" name="Import" value="1">
<input type="radio" checked name="Import" value="0">

<input name=Match value="ID" type=checkbox>
<input name=Match value="Names" type=checkbox>
<input name=Match value="Profile" type=checkbox>

phranque

11:14 am on May 23, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What is the code to disable the three checkboxes whenever the Impor raidio option is changed to 1 and enable them when its set to 0?

something along these lines might work:

<script language="JavaScript" type="text/JavaScript">
<!--
function chekMatch() {
var x=document.getElementById("Match");
x[0].checked = "true";
x[1].checked = "true";
x[2].checked = "true";
}
function unchekMatch() {
var x=document.getElementById("Match");
x[0].checked = "false";
x[1].checked = "false";
x[2].checked = "false";
}
//-->
</script>

<input type="radio" name="Import" value="1" onClick="unchekMatch()">
<input type="radio" checked name="Import" value="0" onClick="chekMatch()">

<input name="Match" value="ID" type=checkbox checked>
<input name="Match" value="Names" type=checkbox checked>
<input name="Match" value="Profile" type=checkbox checked>

you could generalize it to use one method and passing a T/F flag and/or the form handle and/or the checkbox form element name.
you might also need to generalize the method for an arbitrary-length array of checkboxes.

aspdaddy

3:31 pm on May 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks,

Im getting an error on Line 5, '0' is null or not an object, but Im assuming this is an IE6 specific thing.

phranque

7:37 am on May 25, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



this code is theoretical as it has been untested.
does it work with other browsers?