/    Sign up×
Community /Pin to ProfileBookmark

need help with a form

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>
[/CODE]

cheers

broken//barrier

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceApr 05.2005 — 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.[/QUOTE]
Describe what the logic should be.
×

Success!

Help @broken__barrier spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...