Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

1. ## Multiplying Form Fields

I am working on the form below.
I want to add together the #'s from the Girls and Adults field then multiply that # by the Hours field and have the total placed in the Total Hours Given field.

Ex.
Girls = 2
Hours = 10
Total HoursGiven = 20

Then I want to take the Total Hours Given # and add it to the #'s in the Girl Hours and Adult Hours fields and have that # placed in the New Total # of hours given field.

Ex.
Total Hours Given = 20
Girls Hours = 5
New Total # of hours given = 30

I have started working with the first part but can't get the multiplication to work. I was wondering if someone could take a look and tell me what I am doing wrong.

Code:
```<html>

<script type="text/javascript">

//Calulate Total
function startTotal(){
interval = setInterval("calcTotal()",1);
}
function calcTotal(){
var g1girl = document.sog.g1GirlPar1.value;
document.sog.g1HoursGiven1.value = (g1girl * 1) + (g1adult * 1) * (g1hours * 1);

}
function stopTotal(){
clearInterval(interval);
}

</script>

<body>

<form name="sog" method="post" action="send.asp" >
<table width="500" border="0" cellpadding="3" cellspacing="0" bgcolor="#000000" class="main">

<tr valign="top" bgcolor="#FFFFFF" class="main">
<td>Girls:</td>
<td align="left"><input name="g1GirlPar1" type="text" size="5" value="" class="shadowSm" onFocus="startTotal();" onBlur="stopTotal();"></td>
</tr>

<tr valign="top" bgcolor="#FFFFFF" class="main">
</tr>

<tr valign="top" bgcolor="#FFFFFF" class="main">
<td>Hours:</td>
</tr>

<tr valign="top" bgcolor="#FFFFFF" class="main">
<td>Total Hours Given:</td>
<td align="left">

</td>
</tr>

<tr valign="top" bgcolor="#FFFFFF" class="main">
<td>Girl Hours:</td>
<td align="left"><input name="g1GirlHours1" type="text" size="5" value="" class="shadowSm"> </td>
</tr>

<tr valign="top" bgcolor="#FFFFFF" class="main">
</tr>

<tr valign="top" bgcolor="#FFFFFF" class="main">
<td>New Total # of hours given:</td>
<td align="left">
<input name="g1Hours1" type="text" size="5" value="" class="shadowSm"> Total Hours Given + Girl Hours + Adult Hours
</td>
</tr>

<tr valign="top" bgcolor="#FFFFFF" class="main">
<td><input type="submit" value="Submit" class="xml-icon"></td>
<td align="left">&nbsp;</td>
</tr>
</table>

</form>

</body>
</html>```

• Code:
`  document.sog.g1HoursGiven1.value = ((g1girl * 1) + (g1adult * 1)) * (g1hours * 1);`

Quizmaster: In Roman Catholicism, baptism, confirmation and matrimony are three of the seven what?

• ## Users who have thanked Philip M for this post:

slash75 (01-16-2009)

• Of course that is the one thing I didn't think of! Thank you.

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•