I have need of some help...i am working on a form in javascript and am wanting to create a function to total the value of checkboxes when they are checked. i have found many examples, and have a little bit done but it won't total up the values.
this is the function:
<script type="text/javascript" language="JavaScript">
//
// Function for Form F2
function checkTotal() {
document.listForm.total.value = '';
var sum = 0;
for (i=0;i<document.listForm.choice.length;i++) {
if (document.listForm.choice[i].checked) {
sum = sum + parseInt(document.listForm.choice[i].value);
}
}
document.listForm.total.value = sum;
}
and the form that i have is:
</HEAD>
<BODY bgcolor="beige">
<form name="listForm">
<input type="checkbox" name="choice" value="30" onclick="javascript: checkTotal(listForm)"/> (30.00)<br>
<input type="checkbox" name="choice" value="20" onclick="javascript: checkTotal(listForm)"/> (20.00)/each<br>
<input type="checkbox" name="choice" value="0" onclick="javascript: checkTotal(listForm)"/> (free)<br>
<input type="checkbox" name="choice" value="0" onclick="javascript: checkTotal(listForm)"/> (free)<br>
<input type="checkbox" name="choice" value="12" onclick="javascript: checkTotal(listForm)"/>(free)<br>
Total: <input type="text" size="5" name="total" value="20"/>
</fieldset>
if i could get some help on where I have messed up i would appreciate it a ton!
thanks,