Slytherine
10-19-2003, 06:55 AM
Hi all!
I am a High School student now involving in a mini project with SHOPPING CARTS.
Some Questions :
<html>
<head>
<script language="JavaScript">
function anyCheck(form) {
var total = 0;
var max = form.ckbox.length;
for (var check = 0; check < max; check++) {
if (eval("document.Feedback.ckbox[" + check + "].checked") == true) {
total += 1;
}
}
var txt = total ;
document.forms[0].haha.value = txt
}
</script>
</head>
<body>
<form name="Feedback" action="formSent.html" method="post"
>
<input type=checkbox name=ckbox onClick="anyCheck(this.form)">
<input type=checkbox name=ckbox onClick="anyCheck(this.form)">
<input type=checkbox name=ckbox onClick="anyCheck(this.form)">
<input type=text name=haha size=1>
<input type="submit" name="Submit" onClick="anyCheck(this.form)" value="Buy"></td>
</form>
</body>
</html>
These are the codes in my document, currently
QS: How do i stop the user from submitting the form when he does not check on the checkbox.
One hint is that: When the user check on one box, the textbox will show "1". Similarly for 2 and 3 boxes.
I am a High School student now involving in a mini project with SHOPPING CARTS.
Some Questions :
<html>
<head>
<script language="JavaScript">
function anyCheck(form) {
var total = 0;
var max = form.ckbox.length;
for (var check = 0; check < max; check++) {
if (eval("document.Feedback.ckbox[" + check + "].checked") == true) {
total += 1;
}
}
var txt = total ;
document.forms[0].haha.value = txt
}
</script>
</head>
<body>
<form name="Feedback" action="formSent.html" method="post"
>
<input type=checkbox name=ckbox onClick="anyCheck(this.form)">
<input type=checkbox name=ckbox onClick="anyCheck(this.form)">
<input type=checkbox name=ckbox onClick="anyCheck(this.form)">
<input type=text name=haha size=1>
<input type="submit" name="Submit" onClick="anyCheck(this.form)" value="Buy"></td>
</form>
</body>
</html>
These are the codes in my document, currently
QS: How do i stop the user from submitting the form when he does not check on the checkbox.
One hint is that: When the user check on one box, the textbox will show "1". Similarly for 2 and 3 boxes.