Hi,
I have a form which needs more javascript validation than I have the knowledge to provide.
The form contains 5 checkboxes. The first condition I've managed to code the validation for: Either option 1 OR option 2 can be - but doesn't have to be - checked.
The second condition is that IF option 1 or 2 ARE checked then options 3, 4 and 5 become enabled. Obviously, if both option 1 and option 2 become unchecked, these "conditional" options must become unchecked and disabled.
I'd really appreciate a little assistance here, my javascript is just not up to this yet!
The page is here.
And the code is as follows:
Thanks for any help and guidance you can give me.
Rob
I have a form which needs more javascript validation than I have the knowledge to provide.
The form contains 5 checkboxes. The first condition I've managed to code the validation for: Either option 1 OR option 2 can be - but doesn't have to be - checked.
The second condition is that IF option 1 or 2 ARE checked then options 3, 4 and 5 become enabled. Obviously, if both option 1 and option 2 become unchecked, these "conditional" options must become unchecked and disabled.
I'd really appreciate a little assistance here, my javascript is just not up to this yet!
The page is here.
And the code is as follows:
Code:
<html>
<head>
<title>checkboxtastic</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="form_style.css">
<script type="text/javascript">
function oneOrNoCheckboxGroup(checkbox)
{
var checkboxGroup = checkbox.form[checkbox.name];
for (var c = 0; c < checkboxGroup.length; c++)
if (checkboxGroup[c] != checkbox)
checkboxGroup[c].checked = false;
}
</script>
</head>
<body>
<form action="checkbox.asp" method="post" id="form1" name="form1">
<table border="0" width="600">
<tr class="an10" bgcolor="#EAD5EA">
<td class="an10" bgcolor="#EAD5EA"><b><i>Either</i></b></td>
<td class="an10" bgcolor="#EAD5EA">Option 1</td>
<td align="left" class="an10" bgcolor="#EAD5EA"><input type="checkbox" name="option" id="option1" onclick="oneOrNoCheckboxGroup(this);"></td>
</tr>
<tr class="an10" bgcolor="#EAD5EA">
<td class="an10" bgcolor="#EAD5EA"><b><i>Or</i></b></td>
<td class="an10" bgcolor="#EAD5EA">Option 2</td>
<td align="left" class="an10" bgcolor="#EAD5EA"><input type="checkbox" name="option" id="option2" onclick="oneOrNoCheckboxGroup(this);"></td>
</tr>
<tr class="an10" bgcolor="#EAD5EA">
<td class="an10" bgcolor="#EAD5EA"></td>
<td align="left" class="an10" bgcolor="#EAD5EA">Option 3</td>
<td align="left" class="an10" bgcolor="#EAD5EA"><input type="checkbox" name="option3" id="option3" disabled></td>
</tr>
<tr class="an10" bgcolor="#EAD5EA">
<td class="an10" bgcolor="#EAD5EA"></td>
<td align="left" class="an10" bgcolor="#EAD5EA">Option 4</td>
<td align="left" class="an10" bgcolor="#EAD5EA"><input type="checkbox" name="option4" id="option4" disabled></td>
</tr>
<tr class="an10" bgcolor="#EAD5EA">
<td class="an10" bgcolor="#EAD5EA"></td>
<td align="left" class="an10" bgcolor="#EAD5EA">Option 5</td>
<td align="left" class="an10" bgcolor="#EAD5EA"><input type="checkbox" name="option5" id="option5" disabled></td>
</tr>
</table>
</form>
</body>
</html>
Thanks for any help and guidance you can give me.
Rob