Total members 11890 |It is currently Thu Apr 25, 2024 8:51 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Ok, so here is the deal, I need some help with finalizing my code. I have the calculate sum function at the bottom but I guess it is written wrong? anyways, I can not get the total of my numbers to summeraze in my total box at the bottom. Here is my code. any help would be greatly appreciated!
Code:
<html>
<SCRIPT language = "JavaScript">
function calculate1() {
A = document.frmOne.txtFirstNumber1.value;
B = document.frmOne.txtSecondNumber1.value;
C = (A * B);
document.frmOne.txtThirdNumber1.value = C;
}

function calculate2() {
A = document.frmTwo.txtFirstNumber2.value;
B = document.frmTwo.txtSecondNumber2.value;
C = (A * B);
document.frmTwo.txtThirdNumber2.value = C;
}
</SCRIPT>
<BODY>
<P><FONT SIZE="+2">F.O.C.U.S. Life Insurance Calculator</FONT></P>
<table width="600" border="2" cellpadding="2">
<tr>
<td width="169"><font size="+3">F</font> - Funeral Expenses:</td>
<td width="186"><input type=TEXT name="input_A" size=25></td>
<td width="215"><font size="2">Flowers, Burial Plots, Caskets, Professional and Transportation Services, Food, Airfare, and

Others. Typically, the average funeral in the US is between $8,000 - $10,000. </font></td>
</tr>
<tr>
<td><font size="+3">O </font>- Other Debts:</td>
<td><input type=TEXT name="input_B" size=25></td>
<td><font size="2">Other Debts: Mortgages, Vehicle Loans, Credit Cards and other fiduciary responsibilities.</font></td>
</tr>
<tr>
<td><font size="+3">C </font>- College </td>
<td><FORM NAME = frmOne>
<p>Number of Children
<select name="txtFirstNumber1" id="txtFirstNumber1">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</p>
<p>Type of College
<select name="txtSecondNumber1" id="txtSecondNumber1">
<option value="40000">Public/$10,000 per year</option>
<option value="100000">Private/$25,000 per year</option>
</select>
</p>
<P>
<input type = Button name = b1 value = "Add Numbers" onClick = "calculate1()">
<P>
  <input type = Text name="txtThirdNumber1" size = 25 value = "">

</FORM></td>


<td><table cellspacing="0" cellpadding="0">
<td colspan="8" height="32" width="515"><font size="2">The average cost of a (4) year public school is $10,000 per year and

$25,000 per year for private universities. You will want to choose the number of children you have here, if "0" leave

blank.</font></td>
</table></td>
</tr>
<tr>
<td><font size="+3">U</font> - Unforeseen Expenses </td>
<td><input type=TEXT name="input_A4" size=25></td>
<td> </td>
</tr>
<tr>
<td><font size="+3">S</font> - Salary </td>
<td><div align="center">
<FORM NAME = frmTwo>
<p align="left">Salary Needed Per Year</p>
<p align="left">
  <input type = Text name = "txtFirstNumber2" size = 15 value ="">
</p>
<p align="left">Number of Years</p>
<p align="left">
  <select name="txtSecondNumber2" id="txtsecondNumber2">
    <option value="5">5 Years</option>
    <option value="10">10 Years</option>
    <option value="15">15 Years</option>
    <option value="20">20 Years</option>
    <option value="25">25 Years</option>
    <option value="30">30 Years</option>
    <option value="35">35 Years</option>
    <option value="40">40 Years</option>
  </select>
</p>
<P align="left">
<input type = Button name = b12 value = "Add Numbers" onClick = "calculate2()">
<P align="left">
<input type = Text name="txtThirdNumber2" size = 25 value = "">
</FORM>
</div></td>
<td> </td>
</tr>
</table>
<table width="601" border="0">
  <tr>
    <td width="179">&nbsp;</td>
    <td width="382"><input type="button" value="Add Numbers" name="AddButton" onClick="CalculateSum(input_A.value, input_B.value, txtThirdNumber1.value,input_A4.value, txtThirdNumber2.value,)">
    <input type="button" value="Clear Fields" name="ClearButton" onClick="ClearForm(this.form)"></td>
    <td width="26">&nbsp;</td>
  </tr>
</table>
<table width="600" border="0">
  <tr>
    <td><div align="center"><font size="+2">F.O.C.U.S Total Life Insurance Needed=</font>
        <INPUT TYPE=TEXT NAME="Answer" SIZE=12>
    </div></td>
  </tr>
</table>
<P>&nbsp;</P>
<P>&nbsp;</P>
</BODY>
</HTML>





Last edited by DrRakha on Tue Dec 16, 2008 1:23 pm, edited 1 time in total.
change Title ,add [code] bbcode


Author:
Newbie
User avatar Posts: 2
Have thanks: 0 time

what is CalculateSum function ?? Where is its implemntaion !

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

i guess i dont know the answer to that. I need to add the following fields. input_A.value, input_B.value, txtThirdNumber1.value,input_A4.value, txtThirdNumber2.value

Like I said I am REALLY new at this and not sure how to continue. any help would be great.


Author:
Newbie
User avatar Posts: 2
Have thanks: 0 time

Code:
<html>
<SCRIPT language = "javascript">
function SumAll( value1, value2, value3, value4, value5)
{

  var sum=((((value1+value2)+value3)+value4)+value5);
Answer.value=sum;
}

function calculate1()
{
A = document.frmOne.txtFirstNumber1.value;
B = document.frmOne.txtSecondNumber1.value;
C = (A * B);
document.frmOne.txtThirdNumber1.value = C;
}

function calculate2() {
A = document.frmTwo.txtFirstNumber2.value;
B = document.frmTwo.txtSecondNumber2.value;
C = (A * B);
document.frmTwo.txtThirdNumber2.value = C;
}

</SCRIPT>
<BODY>
<P><FONT SIZE="+2">F.O.C.U.S. Life Insurance Calculator</FONT></P>
<table width="600" border="2" cellpadding="2">
<tr>
<td width="169"><font size="+3">F</font> - Funeral Expenses:</td>
<td width="186"><input type="TEXT" name="input_A" size="25"></td>
<td width="215"><font size="2">Flowers, Burial Plots, Caskets, Professional and Transportation Services, Food, Airfare, and

Others. Typically, the average funeral in the US is between $8,000 - $10,000. </font></td>
</tr>
<tr>
<td><font size="+3">O </font>- Other Debts:</td>
<td><input type=TEXT name="input_B" size=25></td>
<td><font size="2">Other Debts: Mortgages, Vehicle Loans, Credit Cards and other fiduciary responsibilities.</font></td>
</tr>
<tr>
<td><font size="+3">C </font>- College </td>
<td><FORM NAME = frmOne>
<p>Number of Children
<select name="txtFirstNumber1" id="txtFirstNumber1">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</p>
<p>Type of College
<select name="txtSecondNumber1" id="txtSecondNumber1">
<option value="40000">Public/$10,000 per year</option>
<option value="100000">Private/$25,000 per year</option>
</select>
</p>
<P>
<input type="Button" name="b1" value = "Add Numbers" onClick = "javascript:calculate1()">
<P>
  <input type="Text" name="txtThirdNumber1" size="25" value="">

</FORM></td>


<td><table cellspacing="0" cellpadding="0">
<td colspan="8" height="32" width="515"><font size="2">The average cost of a (4) year public school is $10,000 per year and

$25,000 per year for private universities. You will want to choose the number of children you have here, if "0" leave

blank.</font></td>
</table></td>
</tr>
<tr>
<td><font size="+3">U</font> - Unforeseen Expenses </td>
<td><input type="TEXT" name="input_A4" size="25"></td>
<td> </td>
</tr>
<tr>
<td><font size="+3">S</font> - Salary </td>
<td><div align="center">
<FORM NAME ="frmTwo">
<p align="left">Salary Needed Per Year</p>
<p align="left">
  <input type="Text" name="txtFirstNumber2" size="15" value ="">
</p>
<p align="left">Number of Years</p>
<p align="left">
  <select name="txtSecondNumber2" id="txtsecondNumber2">
    <option value="5">5 Years</option>
    <option value="10">10 Years</option>
    <option value="15">15 Years</option>
    <option value="20">20 Years</option>
    <option value="25">25 Years</option>
    <option value="30">30 Years</option>
    <option value="35">35 Years</option>
    <option value="40">40 Years</option>
  </select>
</p>
<P align="left">
<input type="Button" name="b12" value="Add Numbers" onClick="calculate2()">
<P align="left">
<input type="Text" name="txtThirdNumber2" size="25" value="">
</FORM>
</div></td>
<td> </td>
</tr>
</table>
<table width="601" border="0">
  <tr>
    <td width="179">&nbsp;</td>
    <td width="382"><input type="button" value="Add Numbers" name="AddButton" onClick="
   SumAll(input_A.value, input_B.value, frmOne.txtThirdNumber1.value,input_A4.value, frmTwo.txtThirdNumber2.value)">
    <input type="button" value="Clear Fields" name="ClearButton" onClick=""></td>
    <td width="26">&nbsp;</td>
  </tr>
</table>
<table width="600" border="0">
  <tr>
    <td><div align="center"><font size="+2">F.O.C.U.S Total Life Insurance Needed=</font>
        <INPUT TYPE="TEXT" NAME="Answer" SIZE=12>
    </div></td>
  </tr>
</table>
<P>&nbsp;</P>
<P>&nbsp;</P>
</BODY>
</HTML>

Solved for you :)

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 4 posts ] 

  Related Posts  to : calculate sum of many text inputs in javascript
 Need help with JavaScript function calculate the total pric!     -  
 Typing Status Bar Text javascript code     -  
 Inputs in HTML5     -  
 Able to Copy Text from Uneditable Text Boxes(JTextfields)     -  
 Calculate score of the student     -  
 Calculate the sum of values in an array     -  
 How to Calculate Volume of a Rectangle     -  
 Calculate process time     -  
 Calculate euclidean distances     -  
 calculate speed of a car in javaCV     -  



Topic Tags

JavaScript Variables
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com