Check boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I make the selection of one check box automatically select other
check boxes in the same form? Is this possible? For example, if a section
of my form is not applicable, I want a user to check the N/A box and then
have other check boxes in that section automatically become selected. Thanks
for any help you can give me.
 
You would use JavaScript. The checkbox has a "checked" attribute which is
either true or false. It also has an "onclick" event. So, for example (paste
into a new empty Page in FrontPage and Preview to see demo):

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>CheckBox OnClick Demo</title>
</head>

<body>

<form>
<p><input type="checkbox" name="C1"
id="CheckBox1" onclick="SetBoxes()" value="ON" checked>
CheckBox1 (Click To Set other CheckBoxes)</p>
<p><input type="checkbox" name="C2"
id="CheckBox2" value="ON" checked> CheckBox2</p>
<p><input type="checkbox" name="C3"
id="CheckBox3" value="ON"> CheckBox3</p>
<script type="text/javascript"><!--
function SetBoxes()
{
if (document.getElementById("CheckBox1").checked)
{
document.getElementById("CheckBox2").checked = true;
document.getElementById("CheckBox3").checked = false;
}
else
{
document.getElementById("CheckBox2").checked = false;
document.getElementById("CheckBox3").checked = true;
}
}
// --></script>
</form>

</body>

</html>

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
I'd rather be a hammer than a nail.

"Need Help with Frontpage forms"
 
Back
Top