Hi all,
The following script loads the 1-3.htm page if one, two or three checkboxes have been checked, the 4-6.htm page if four, five or six, and the 7-9.htm page if seven, eight or nine checkboxes have been checked.
My question: how to make the script load a page depending on WHICH checkboxes have been checked, not how many? For example if box 1 and box 4 are checked, it loads page 1-4.htm. If boxes 2 and 6 are checked it loads page 2-6.htm.
Many thanks!
The Code*
<html>
<head>
<script language="JavaScript"><!--
function redirect (form, group) {
var numberClicked = 0;
for (var i=0; i<form.elements.length; i++) {
if (form.elements.name == group && form.elements.type == 'checkbox' && form.elements.checked)
numberClicked++;
}
if (numberClicked <= 3) url = '1-3.htm'
else if (numberClicked <= 6) url = '4-6.htm';
else url = '7-9.htm';
location.href = url;
return false;
}
//--></script>
</head>
<body>
<form onSubmit="return redirect(this,'group1')">
<input type="checkbox" name="group1">
<input type="checkbox" name="group1">
<input type="checkbox" name="group1">
<input type="checkbox" name="group1">
<input type="checkbox" name="group1">
<input type="checkbox" name="group1">
<input type="checkbox" name="group1">
<input type="checkbox" name="group1">
<input type="checkbox" name="group1">
<input type="submit" value="Submit">
</form>
</body>
</html>