I have created a form where the text fields get calculated into a total text field. I have written a script that correctly calculates the text field values and displays the total in the total text field. My problem is I have also added check boxes to the form if the user checks any of the check boxes the text field value needs to be totaled into another total text field. I am not quite sure what I need to do in order to make this happen can any one help????????????????
[CODE]
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<title>Untitled Document</title>
<script language=”JavaScript”><!–
function calculate(what) {
for (var i=1,answer=0;i<6;i++)
answer += what.elements[‘textField’ + i].value – 0;
what.answer.value = answer;
}
//–></script>
</head>
<body>
<form name=”qprfunding”>
<table cellpadding=”5″ width=”90%” border=”1″>
<tr>
<td colspan=”3″><strong>Funding Sources</strong></td>
</tr>
<tr>
<th align=”left” width=”40%”> Funding Source Name </th>
<th align=”left” width=”30%”> Matching Funds </th>
<th align=”left” width=”30%”> Fund Amount </th>
</tr>
<tr>
<td><select>
<option selected>Select Funding Source</option>
<option>Funding Source 1</option>
<option>United Way</option>
<option>Red Cross</option>
</select>
</td>
<td><input type=”checkbox” name=”checkbox1″>
Yes </td>
<td>$
<input type=”text” size=”10″ name=”textField1″ onBlur=”calculate(this.form)”></td>
</tr>
<tr>
<td><select>
<option selected>Select Funding Source</option>
<option>Funding Source 1</option>
<option>United Way</option>
<option>Red Cross</option>
</select>
</td>
<td><input type=”checkbox” name=”checkbox2″>
Yes </td>
<td>$
<input type=”text” size=”10″ name=”textField2″ onBlur=”calculate(this.form)”></td>
</tr>
<tr>
<td><select>
<option selected>Select Funding Source</option>
<option>Funding Source 1</option>
<option>United Way</option>
<option>Red Cross</option>
</select>
</td>
<td><input type=”checkbox” name=”checkbox3″>
Yes </td>
<td>$
<input type=”text” size=”10″ name=”textField3″ onBlur=”calculate(this.form)”></td>
</tr>
<tr>
<td><select>
<option selected>Select Funding Source</option>
<option>Funding Source 1</option>
<option>United Way</option>
<option>Red Cross</option>
</select>
</td>
<td><input type=”checkbox” name=”checkbox4″>
Yes </td>
<td>$
<input type=”text” size=”10″ name=”textField4″ onBlur=”calculate(this.form)”></td>
</tr>
<tr>
<td><select>
<option selected>Select Funding Source</option>
<option>Funding Source 1</option>
<option>United Way</option>
<option>Red Cross</option>
</select>
</td>
<td><input type=”checkbox” name=”checkbox5″>
Yes </td>
<td>$ <input type=”text” size=”12″ name=”textField5″ onBlur=”calculate(this.form)”></td>
</tr>
<tr>
<td colspan=”2″><strong>Matching Funds Total</strong>
</td>
<td>$ <input name=”answer2″ type=”text” id=”ActivityNumber” size=”10″ tabindex=”1″></td>
</tr>
<tr>
<td colspan=”2″><strong>Other Funds Total</strong>
</td>
<td>$ <input type=”text” size=”10″ name=”answer” id=”ActivityNumber” tabindex=”2″></td>
</tr>
<tr>
<td colspan=”3″><a href=””>Add Additional Funding Sources</a><br>
</td>
</tr>
</table>
</form>
</body>
</html>
cheers
broken//barrier