Click to See Complete Forum and Search --> : need script-can't find
Tenchi6
01-09-2003, 08:17 PM
I need help in finding a script, that is if it exists. It needs to be that when you check the checkboxes the value cannot exceed a certain number. You have the #s 0-11 and you can choose any two as long as it doesn't exceed say 16. So 11 & 10 are invalid while 9 & 7 are. Doesn't matter if it's a drop menu or checks. thanks.
Try something like that:
<html>
<head>
<script language="JavaScript">
<!--
function check(form){
var len = form.elements.length;
val = 0;
for(i=0;i<len;i++)
{
if(form.elements[i].checked == true)
val += parseFloat(form.elements[i].value);
}
if(val > 16){
alert("Result > 16");form.reset();return false;
}
}
//-->
</script>
</head>
<body>
<form name=checker onSubmit="return check(this)">
<input type=checkbox name=check1 value=1>
<input type=checkbox name=check1 value=5>
<input type=checkbox name=check1 value=8>
<input type=checkbox name=check1 value=9>
<input type=checkbox name=check1 value=10>
<input type=checkbox name=check1 value=11>
<input type=checkbox name=check1 value=12>
<input type="Submit" name="" value="Go">
</form>
</body>
</html>
Tenchi6
01-12-2003, 10:45 PM
I'm trying but I'm having a hard time to get it to work.