473,326 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Sum Form Fields in javascript

I have a web page developed in FrontPage that has 7 form boxes that contain dollar amounts. 6 of the amounts can be selected in drop down boxes. 1 box is a text box where an amount can be entered. I would like to get a total of all 7 boxes. I have found routines that work if all 7 boxes are text or all 7 are drop downs. I am a beginner using javasctipt and understand html pretty well.

Is there somewhere that may have such a routine?

Thanks, Lamar
Jun 19 '07 #1
3 1645
bartonc
6,596 Expert 4TB
Let's try the Javascript forum, shall we...
Jun 19 '07 #2
acoder
16,027 Expert Mod 8TB
I have a web page developed in FrontPage that has 7 form boxes that contain dollar amounts. 6 of the amounts can be selected in drop down boxes. 1 box is a text box where an amount can be entered. I would like to get a total of all 7 boxes. I have found routines that work if all 7 boxes are text or all 7 are drop downs. I am a beginner using javasctipt and understand html pretty well.

Is there somewhere that may have such a routine?

Thanks, Lamar
Let's see your code. Usually, if you can access the object (text box of drop down), the value attribute will be enough.
Jun 20 '07 #3
Thanks for the quick response. Here's the code that works where all 7 boxes are drop down boxes.

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">

<title>Fore-Tee Thieves Tournament Registration</title>

<style type="text/css">
.style1 {
font-family: Arial;
font-weight: bold;
}
</style>


<body topmargin="5" bottommargin="5">

<form name="FrontPage_Form1"
action="http://free.allforms.mailjol.net/u/ad169c19x.php"
method="POST"
style="color: #000000; border: 3px double #000000; background-color: #FAFAF8"
onsubmit="return FrontPage_Form1_Validator(this)"
language="JavaScript">

<onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript">

<script type="text/javascript"><!--

function cent(amount) {
return (document.FrontPage_Form1.Total_Amount == Math.floor(document.FrontPage_Form1.Total_Amount.v alue)) ?
document.FrontPage_Form1.Total_Amount.value + '.00' :
( (document.FrontPage_Form1.Total_Amount.value*10 == Math.floor(document.FrontPage_Form1.Total_Amount.v alue*10)) ?
document.FrontPage_Form1.Total_Amount.value + '.00' :
document.FrontPage_Form1.Total_Amount.value);
}

function updatesum() {
document.FrontPage_Form1.Total_Amount.value =
(document.FrontPage_Form1.Current_Dues.options[document.FrontPage_Form1.Current_Dues.selectedInde x].text-0) +
(document.FrontPage_Form1.Past_Due.options[document.FrontPage_Form1.Past_Due.selectedIndex].text-0) +
(document.FrontPage_Form1.Annual_Dues.options[document.FrontPage_Form1.Annual_Dues.selectedIndex].text-0) +
(document.FrontPage_Form1.Hole_In_One.options[document.FrontPage_Form1.Hole_In_One.selectedIndex].text-0) +
(document.FrontPage_Form1.Advance_Pay.options[document.FrontPage_Form1.Advance_Pay.selectedIndex].text-0) +
(document.FrontPage_Form1.Other.options[document.FrontPage_Form1.Other.selectedIndex].text-0) +
(document.FrontPage_Form1.Guest_Fees.options[document.FrontPage_Form1.Guest_Fees.selectedIndex].text-0);

{document.FrontPage_Form1.Total_Amount.value = cent(Math.round(document.FrontPage_Form1.Total_Amo unt*Math.pow(6,2))/Math.pow(6,2));
}
}

//--></script>

<div align="center">
<table border="1" width="100%" height="771" style="border: 3px double #000000" bgcolor="#F7F7F2">
<tr>
<td height="93" width="100%">

<p align="center">
<b><font face="Arial" size="4">This Months Tournament</font></b><br><br>

<input name="Course_Name"
size="76"
value="Boulder Creek Golf &amp; Country Club - Sunday - July 22nd, 2007 - 10:00 AM"
style="font-family: Arial; font-size: 14pt; font-weight: bold; color: #000000; border: 5px double #800000; background-color: #C8C8AC; float:center"></p>

<style="margin-left: 4px"><font size="4" face="Arial">
<font face="Arial" size="3">

</td>
</tr>
<tr>
<td height="52" width="100%">

<p style="margin-left: 4px">
<font face="Arial" size="4">Name:</font><font size="3" face="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;
<!--webbot bot="Validation" s-data-type="String" b-value-required="TRUE" i-minimum-length="1" i-maximum-length="80" -->
<input name="Member_Name"
size="30"
maxlength="30"
style="font-weight: 700; width: 260px;"></font><b>

<font face="Arial">&nbsp;&nbsp;&nbsp;e-mail id: </font></b>
<font size="3" face="Arial">
&nbsp;<!--webbot bot="Validation" b-value-required="TRUE" i-minimum-length="1" i-maximum-length="40" --><input name="e_mail"
size="40"
maxlength="40"
style="font-weight: 700; width: 294px;"></font></td>
</tr>
<tr>
<td height="72" width="100%">

<b><font face="Arial">I am playing in this tournament&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;</font></b>
<font size="3" face="Arial">
&nbsp;<!--webbot bot="Validation" b-value-required="TRUE" b-disallow-first-item="TRUE" --><select size="1" name="Tournament_Play" style="font-family:Arial; font-size:12pt">
<option selected>Select</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select></font>

<b><font face="Arial"><br>
I desire a cart&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></b><font size="3" face="Arial">
&nbsp;<!--webbot bot="Validation" b-value-required="TRUE" b-disallow-first-item="TRUE" --><select size="1" name="Cart" style="font-family:Arial; font-size:12pt">
<option selected>Select</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select></font></td>
</tr>
<tr>
<td height="78" width="100%">

<p style="margin-left: 4px">&nbsp;<style="margin-left: 4px"><b><font face="Arial">I will be bring </font></b>
<font size="3" face="Arial">&nbsp;
<select name="Guests" size="1" onChange="updatefees()" style="font-size: 10pt; font-family: Arial">
<option selected>0
<option>1
<option>2
<option>3
</select></font>

<b><font face="Arial"> guests&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;
---&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Guests pay:&nbsp; <font size="4">$70.00</font>&nbsp;&nbsp;&nbsp;</font></b></p>

<p style="margin-left: 4px">
<b><font face="Arial">Guest Names
</font></b><font size="4" face="Arial">

<input name="Guest_1" size="25" style="font-weight: 700"></font><b><font face="Arial">
</font></b><font face="Courier New"><font size="4" face="Arial">

<input name="Guest_2" size="25" style="font-weight: 700"></font><b><font face="Arial">
</font></b><font size="4" face="Arial">

<input name="Guest_3" size="25" style="font-weight: 700"></font><b><font face="Arial">
</font></b></td>
</tr>
<tr>
<td height="259" width="100%">

<font size="4" face="Arial"><b><font face="Courier New" size="4">Current Dues: $</font></b><font face="Arial"><font size="3">
<select name="Current_Dues" onChange="updatesum()" size="1" style="font-size: 10pt">
<option selected>.00
<option>70.00
<option>35.00
<option>000.00
</select></font>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;
<marquee style="font-size: 14pt; font-family: Arial; font-weight: bold; border: 5px double #919160; " width="272" loop="1" behavior="slide" height="24">DUE DATE JULY 12TH, 2007</marquee>
</font><br>

<b><font face="Courier New" size="4">&nbsp;&nbsp;&nbsp; Past Due: $</font></b><font face="Arial" size="3">
<select name="Past_Due" onChange="updatesum()" size="1">
<option selected>.00
<option>35.00
<option>70.00
<option>105.00
<option>140.00
<option>175.00
<option>210.00
<option>000.00
</select></font><br>

<b><font size="4" face="Courier New">&nbsp;Annual Dues: $</font></b><font face="Arial"><font size="3">
<select name="Annual_Dues" onChange="updatesum()" size="1">
<option selected>.00
<option>30.00
<option>000.00
</select></font><br>

<b><font face="Courier New" size="4">&nbsp;Hole In One: $</font></b><font face="Arial" size="3">
<select name="Hole_In_One" onChange="updatesum()" size="1">
<option selected>.00
<option>5.00
<option>000.00
</select></font><br>

<font face="Courier New" size="4"><b>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Other: $</b></font><font size="3">
<select name="Other" onChange="updatesum()" size="1">
<option selected>.00
<option>98.25
<option>000.00
</select></font>
<b><font face="Courier New" size="4">Explain in Comments</font></b> <br>

<b><font face="Courier New" size="4">&nbsp;Advance Pay: $</font></b><font size="3">
<select name="Advance_Pay" onChange="updatesum()" size="1">
<option selected>.00
<option>210.00
<option>420.00
<option>840.00
<option>000.00
</select></font>
<br>

<b><font face="Courier New" size="4">&nbsp;&nbsp;Guest Fees: $</font></b><font face="Arial" size="3">

<select size="1" name="Guest_Fees" onChange="updatesum()">
<option selected>.00</option>
<option>70.00</option>
<option>140.00</option>
<option>210.00</option>
</select><br>

<b><font face="Courier New" size="4">&nbsp;&nbsp; Total Due: $</font></b>

<input name="Total_Amount" size="8" style="width: 70px; font-weight:bold; font-size:14pt">


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<marquee width="347"
loop="1"
behavior="slide"
style="font-family: Arial; font-size: 14pt; font-weight: bold; color: #FFFFFF; border: 7px double #C9C9AD; background-color: #000000"
height="27">DUES MUST BE CURRENT TO PLAY</marquee></td>
</tr>
<tr>
<td height="197" width="100%">

<style="margin-left: 4px"><font face="Arial" size="3">

<p style="margin-left: 4px"><font face="Arial"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;
Comments:</b>&nbsp; </font>

<textarea rows="5" name="Comments" cols="39" style="border:5px double #E2E2C5; font-family: Arial; font-size: 8pt"></textarea></p>
<p style="margin-left: 4px"><font face="Arial" color="#800000"><b>
<font color="#005500" size="4" face="Arial">
<align= "left">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;

<input type="submit"
value="Submit"
name="B3"
style="color: #000000; font-family: Arial; font-size: 10pt; font-weight: bold; border: 5px double #800000; background-color: #CFCFB8">

<input type="reset"
value="Reset"
name="B4"
style="color: #000000; font-family: Arial; font-size: 10pt; font-weight: bold; border: 5px double #800000; background-color: #CFCFB8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;
</font></b></font><b><font face="Arial">Mail your check to:&nbsp;</font></b>
<b><font face="Arial">Larry Smith</font></b><br>
<b><font face="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 14975 Norton Street</font></b><br>
<b><font face="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; San Leandro,
CA&nbsp; 94579-1407</font></b></p></td>
</tr>
</table>
</div>
</body>
</html>
Jun 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: nate | last post by:
Hello, Does anyone know where I can find an ASP server side script written in JavaScript to parse text fields from a form method='POST' using enctype='multipart/form-data'? I'd also like it to...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
4
by: plumba | last post by:
Let me explain.... I have a form (most of which you guys have helped me with!!). The initial problem I was having is that it was holding the data in the fields after submit, I resolved this by...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.