title: Javascript Adding Two Decimal Places
body: <p>This is my Code so far. I want to know how to return the answer with two decimal places. EX. Instead of 515.3 I want 515.30 or instead of 500 I want it to return 500.00.</p>
  
  <pre><code>&lt;HTML&gt;
  &lt;HEAD&gt;
  &lt;TITLE&gt;Simple Adder&lt;/TITLE&gt;
  &lt;SCRIPT LANGUAGE="JavaScript"&gt;
  function CalculateSum(Atext, form)
  {
  var A = parseFloat(Atext);
  form.Answer.value = A * .03+.30+A;
  }
  function ClearForm(form)
  {
  form.input_A.value = "";
  form.Answer.value = "";
  }
  
  // end of JavaScript functions --&gt;
  &lt;/SCRIPT&gt;
  &lt;/HEAD&gt;
  
  &lt;BODY&gt;
  
  &lt;P&gt;&lt;FONT SIZE="+2"&gt;Credit Card Payment Calculator&lt;/FONT&gt;&lt;/P&gt;
  
  &lt;FORM NAME="Calculator" METHOD="post"&gt;
  &lt;P&gt;Enter Base Rent: &lt;INPUT TYPE=TEXT NAME="input_A" SIZE=10&gt;&lt;/P&gt;
  &lt;P&gt;&lt;INPUT TYPE="button" VALUE="Calculate Rent &amp; Fees Payment" name="AddButton"              onClick="CalculateSum(this.form.input_A.value, this.form)"&gt;&lt;/P&gt;
  &lt;P&gt;&lt;INPUT TYPE="button" VALUE="Clear Fields" name="ClearButton"    onClick="ClearForm(this.form)"&gt;&lt;/P&gt;
  &lt;P&gt;Final Amount = &lt;INPUT TYPE=TEXT NAME="Answer" SIZE=12&gt;&lt;/P&gt;
  &lt;/FORM&gt;
  
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>