Panoscha32
asked on
checkboxes - vbscript or javascript
hello there! I have in an ASP file the following checkboxes:
<input type="checkbox">Choice 1<br>
<input type="checkbox">Choice 2<br>
<input type="checkbox">Choice 3<br>
<p>
<input type="checkbox">Checked<br >
<input type="checkbox">Unchecked
</p>
I want each time I select the 'Checked' checkbox, Choice1, Choise2 and Choice3 boxes to be selected. And each time I select 'Unchecked' the three previous to be unselected.
<input type="checkbox">Choice 1<br>
<input type="checkbox">Choice 2<br>
<input type="checkbox">Choice 3<br>
<p>
<input type="checkbox">Checked<br
<input type="checkbox">Unchecked
</p>
I want each time I select the 'Checked' checkbox, Choice1, Choise2 and Choice3 boxes to be selected. And each time I select 'Unchecked' the three previous to be unselected.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Looks good but for some reason it doesn't work. I receive at the buttom of my browser this annoying message 'Error on page'.
ASKER
OK i found it. Thanks very much. The only ommission was that:
<form method="post"><form>
inside <body> section. So here it goes:
<html>
<head>
<title>some title</title>
<script language="javascript">
<!--
function CheckAll() {
document.forms[0].Choice1. checked = true;
document.forms[0].Choice2. checked = true;
document.forms[0].Choice3. checked = true;
}
function UnCheckAll() {
document.forms[0].Choice1. checked = false;
document.forms[0].Choice2. checked = false;
document.forms[0].Choice3. checked = false;
}
//-->
</script>
</head>
<body>
<form method="post">
<input type="checkbox" NAME="Choice1">Choice 1<br>
<input type="checkbox" NAME="Choice2">Choice 2<br>
<input type="checkbox" NAME="Choice3">Choice 3<br>
<p>
<input type="checkbox" NAME="AllCheck" onClick="CheckAll();">Chec ked<br>
<input type="checkbox" NAME="AllUnCheck" onClick="UnCheckAll();">Un checked
</p>
</form>
<body>
</html>
<form method="post"><form>
inside <body> section. So here it goes:
<html>
<head>
<title>some title</title>
<script language="javascript">
<!--
function CheckAll() {
document.forms[0].Choice1.
document.forms[0].Choice2.
document.forms[0].Choice3.
}
function UnCheckAll() {
document.forms[0].Choice1.
document.forms[0].Choice2.
document.forms[0].Choice3.
}
//-->
</script>
</head>
<body>
<form method="post">
<input type="checkbox" NAME="Choice1">Choice 1<br>
<input type="checkbox" NAME="Choice2">Choice 2<br>
<input type="checkbox" NAME="Choice3">Choice 3<br>
<p>
<input type="checkbox" NAME="AllCheck" onClick="CheckAll();">Chec
<input type="checkbox" NAME="AllUnCheck" onClick="UnCheckAll();">Un
</p>
</form>
<body>
</html>
function CheckAll() {
for(i=1; i<4; i++) {
eval('document.forms[0].Ch
}
}