Posted by X l e c t r i c on 10/14/13 11:36
I'm no guru, but the code below works.
Mark Parnell has a good point about being user friendly for those who
have JavaScript disabled. To accomplish that, in the code below:
remove disabled="disabled" from the checkboxes.
and change the body to:
<body onload="setForm();">
Also, some text explaining that clicking on that radio button enables
the following checkboxes would be nice.
You can change the radio button and checkbox names/values to what you
want. Just make sure the checkboxes all have the same name. Also make
sure you change the names in the statements in the changeChek() and
setForm() functions in the JavaScript program.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function changeChek()
{
for (var i = 0; i < document.fone.cone.length; i++)
{
document.fone.cone[i].disabled = false;
}
}
function setForm()
{
document.fone.reset();
for (var i = 0; i < document.fone.cone.length; i++)
{
document.fone.cone[i].disabled = true;
}
}
//-->
</script>
</head>
<body>
<form action="" name="fone">
<div>
<input type="radio" name="rone" value="rad" onclick="changeChek();">
<p>
<input type="checkbox" name="cone" value="chek1" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek2" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek3" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek4" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek5" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek6" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek7" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek8" disabled="disabled">
<p>
<input type="button" value="Reset" onclick="setForm();">
</div>
</form>
</body>
</html>
Navigation:
[Reply to this message]
|