TheCandyman
Technical User
I have a page where 10 people can enter their name and click one of two possible checkbox for each person(adult or child). I think i have this correct, but i just can't get any part of it to work. What i want is when a checkbox is clicked, it checks that a name is entered in the textbox and if so then loop through each name box to figure up a total price for display.
In <Head>
Form:
In <Head>
Code:
function displ()
{
temp=0;
for (Count = 1; Count < 11; Count++) {
if (document.form1.Name[Count].value != "") {
alert (document.form1.Name[Count]);
if (form.Adult[Count].checked == 1) {temp=temp + parseInt(30)}
if (form.Adult[Count].checked == 1) {temp=temp + parseInt(15)}
alert (temp);
}
}
document.form1.Amount.value = temp ;
return true;
}
Form:
Code:
<form action="CC.asp" method="post" name="form1" class="MyForm">
<input type="text" size="30" name="Name1" value="" onclick="return displ();" class="text" />
<input name="Adult1" type="checkbox" value="" onclick="return displ();" />
<input name="Child1" type="checkbox" value="" onclick="return displ();" />
...
...
...