12. 5. Website. (20)
1. Design (10)
2. Scripting (10)
Name of all checkbox will be same. Here “add” is given
name.
In every checkbox properties, write event name. Here:
onchange=checkTotal().
(Go to form properties-> Advanced edit-> Javascript event
: write “return validateform()”)
<script>
function checkTotal() {
document.index.Total.value =' ';
var sum = 0;
for (i=0;i<document.index.add.length;i++) {
if (document.index.add[i].checked) {
sum = sum + parseInt(document.index.add[i].value);
} } document.index.Total.value = sum; }
function validateform() {
if((document.index.add[0].checked==false) &&
(document.index.add[1].checked==false) &&
(document.index.add[2].checked==false))
{ alert("Select atleast one option");
document.index.add[0].focus();
return false; }
alert("Order Successfully Placed");
}
</script>