Compound Interest Calculator : TextField « Form Control « JavaScript DHTML






Compound Interest Calculator

  
<html>
<head>
<title>Compound Interest Calculator</title>
<script language="JavaScript">
function calculate(formObj)
{
     var presentVal = parseFloat(formObj.presentVal.value);
     var intRate = parseFloat(formObj.intRate.value)/100.;
     var years = parseFloat(formObj.years.value);
   
     var futureVal = presentVal * Math.pow((1.0+intRate),years);
     var totalInt = futureVal - presentVal;
     futureVal = Math.round(futureVal*100.0)/100.0;
     totalInt  = Math.round(totalInt*100.0)/100.0;
   
     formObj.futureVal.value = futureVal;
     formObj.totalInt.value = totalInt;
   
     return;
}
</script>
</head>
   
<body>
<h1>Compound Interest Calculator</h1>
<form name="myform">
<pre>
Present Value:        <input type="text" name="presentVal">
Interest Rate(%):     <input type="text" name="intRate">
Years of Compounding: <input type="text" name="years">
<input type="button" name="calc" value="Calculate" onclick="calculate(myform)">
</pre>
<hr>
<pre>
Total Interest: <input type="text" name="totalInt">
Future Value:   <input type="text" name="futureVal">
<pre>
</form>

</body>
           
         
    
  








Related examples in the same category

1.Text field tab Index
2.Is Text Editable
3.Get vcard name
4.Text Field autocomplete Example
5.TextField focus and select all
6.Show TextField value in Dialog
7.TextField focus, blur, and click action
8.Display textfield value in new page
9.JavaScript Loan Calculator
10.Another TextField jump
11.TextField get Focus and clear content
12.Validate an input field with minimum and maximum values
13.Validate an field with a maximum number of characters
14.Select the textfield and focus
15.Focus an input field
16.Jump to the next field
17.Get textfield value
18. Methods and Properties of the Text Object
19.Selecting Text Upon Focus
20.Assign a default value to a Text object
21.Resetting a Text Object to Default Value
22.Getting and Setting a Text Object's Value
23.Passing a Text Object (as this) to the Function
24.Text Object Select and Focus
25.Data Validation via an onChange event Handler
26.Add textfield dynamically into HTML
27. Firing the onSame Event (FireFox)
28.Numerals Only
29.Letter only, yes no only textfield
30.Auto focus textfield
31.Block enter textfield
32.If the textfield has been changed
33.Check if text field input is a number
34.Call select method to highlight the text field
35.Check if a text field is empty
36.Change the text value in text box into upper case
37.Getting and Setting a Text Object's value Property
38.Feed value from array to text box