Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: HTML 5  |  size: 1.45 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <META http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <script>
  6.         function calcInterestTable(){
  7.                
  8.                 var startAmount = parseInt(document.getElementById("startAmount").value);
  9.                 var interestRate = parseInt(document.getElementById("interestRate").value);
  10.                 var nextYearAmount = startAmount;
  11.                 var newResults;
  12.                 var year = 0;
  13.                 var ruleOf72;
  14.                
  15.                 newResults = 'Interest Table \n\n';
  16.                 while(nextYearAmount < (startAmount * 2)){
  17.                         year++;
  18.                         var addInterest = nextYearAmount * (interestRate/100);
  19.                         nextYearAmount = nextYearAmount+addInterest;
  20.                         newResults += 'By the end of year ' + year + ', you will have $' + nextYearAmount + ' overall. \n';
  21.                 }
  22.                 ruleOf72 = 72 / interestRate;
  23.                 newResults += '\n By the Rule of 72 calculates to ' + ruleOf72 + ' \n\n';
  24.                
  25.                 document.getElementById("results").innerText = newResults;
  26.                
  27.                 return false;
  28.         }
  29. </script>
  30. </head>
  31. <body>
  32.  
  33. <div>
  34.  
  35. <!-- <form name="0.1_input" target="_blank" onsubmit="return window.confirm(&quot;You are submitting information to an external page.\nAre you sure?&quot;);"> -->
  36.  
  37. Amount: <input type="text" id="startAmount"><br>
  38.  
  39. Interest Rate: <input type="text" id="interestRate"><br>
  40.  
  41. <!-- <input type="button" value="Calculate Years"> -->
  42. <input type="button" onClick="return calcInterestTable();" value="Calculate Years">
  43.  
  44. <div id="results">
  45.  
  46. </div>
  47. </div>
  48. </body>
  49.  
  50. </html>