title: Trying to do some simple calculations to display on web site using Javascript
body: <p>I am hoping someone can help me out - I am a Javascript novice for sure.  I primarily focus on front-end web site development but a client has asked me if we can display some "cost" options online based on user input.  I was able to succeed in the first pass but once I had to calculate based on a select value things stop working.</p>
  
  <p>Here is my first pass which works for my client and calculates correctly since there is only one unit:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
  function calcform() { 
      with (document.form1)
          { result.value = +number1.value * .75+ +number3.value} /*Calculates Option 1 One Year     Costs.*/
          { result2.value = +number1.value * .75+ +number3.value + +number3.value} /*Calculates     Option 1 Two Years.*/
          { result3.value = +number1.value * .75}/*Calculates Option 1 Leasing Fees.*/
          { result4.value = +number1.value * .08}/*Calculates Option 2 Leasing Fees.*/
          { result5.value = +number1.value * .08 *12 +500}/*Calculates Option 2 One Year Costs.*/
          { result6.value = +number1.value * .08 *24 +500}/*Calculates Option 2 Two Years.*/
      } 
  &lt;/script&gt; 
  &lt;table&gt;
      &lt;form name="form1" action=""&gt; 
          &lt;tr&gt;
              &lt;h5&gt;Prospective Owners Cost Calculator:&lt;/h5&gt;&lt;br/&gt;
              &lt;h4&gt;Enter Your Anticipated Monthly Rent Here:&lt;br/&gt;
                  &lt;input type="text" id="number1" value="" size="20" /&gt;
              &lt;/h4&gt;&lt;br/&gt; 
              &lt;input type="button" id="Calculate" value="Calculate" onclick="calcform()" /&gt;
              &lt;input type="reset" id="reset" value=" Clear "/&gt;
          &lt;/tr&gt;&lt;br/&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;h4&gt;
                      &lt;strong&gt;Option 1&lt;/strong&gt;
                  &lt;/h4&gt;&lt;br/&gt;
                  &lt;h4&gt;Leasing Fee (75% of one month's rent):&lt;br /&gt; 
                      &lt;input type="text" id="result3" value="" size="40" /&gt;
                  &lt;/h4&gt;&lt;br/&gt;
                  &lt;h4&gt;Monthly Management Fee (Fixed $79 x 12 months):&lt;br /&gt;
                      &lt;input type="text" id="number3" value="948" size="40" /&gt;
                  &lt;/h4&gt;&lt;br/&gt; 
                  &lt;h4&gt;Total First Year:&lt;br /&gt; 
                      &lt;input type="text" id="result" value="" size="40" /&gt;
                  &lt;/h4&gt;&lt;br/&gt; 
                  &lt;h4&gt;Total After 2 Years (assuming lease renewal):&lt;br /&gt;
                      &lt;input type="text" id="result2" value="" size="40" /&gt;
                  &lt;/h4&gt;&lt;br/&gt;
              &lt;/td&gt;
              &lt;br/&gt;&lt;br/&gt;
              &lt;td&gt;
                  &lt;br&gt;&lt;br&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;h4&gt;
                      &lt;strong&gt;Option 2&lt;/strong&gt;
                  &lt;/h4&gt;&lt;br/&gt;
                  &lt;h4&gt;Leasing Fee ($500 fixed):&lt;br /&gt;
                      &lt;input type="text" id="number5" value="500" size="40" /&gt;
                  &lt;/h4&gt;&lt;br/&gt;
                  &lt;h4&gt;Monthly Management Fee (8% of Gross Rents):&lt;br /&gt;
                      &lt;input type="text" id="result4" value="" size="40" /&gt;
                  &lt;/h4&gt;&lt;br/&gt;
                  &lt;h4&gt;Total First Year:&lt;br /&gt;
                      &lt;input type="text" id="result5" value="" size="40" /&gt;
                  &lt;/h4&gt;&lt;br/&gt;
                  &lt;h4&gt;Total After 2 Years (assuming lease renewal):&lt;br /&gt;
                      &lt;input type="text" id="result6" value="" size="40" /&gt;
                  &lt;/h4&gt;&lt;br/&gt;
              &lt;/td&gt; 
          &lt;/form&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>I'm trying to add a second form which would go on a different HTML page that would drive additional calculations using a select drop down so a user can indicate number of units, which would drive different calculations.  Told you - I'm a novice!  Greatly appreciate the assistance!</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
  function calcform() 
  { 
  with (document.form1) 
  
  { result1.value = +number1.value * .75}/*Calculates Option 1 Leasing Fees.*/
  { result2.value = +number3.value * +number2.value}/*Calculates Option 1 Mgmt Fees all     units.*/
  
  } 
  &lt;/script&gt; 
  &lt;table&gt;&lt;form name="form1" action=""&gt; 
  &lt;tr&gt;&lt;h5&gt;Prospective Owners Cost Calculator:&lt;/h5&gt;&lt;br/&gt;
  
  &lt;h4&gt;Enter Your Anticipated Monthly Rent Here (Total for all units):&lt;br/&gt;
  &lt;input type="text" id="number1" value="" size="20" /&gt;&lt;/h4&gt;&lt;br/&gt;
  
  &lt;h4&gt;Enter the number of units (from 2-6)&lt;br/&gt;
  &lt;input type="number" name="number2" value="2" min="2" max="6"/&gt;&lt;/h4&gt;&lt;br/&gt; 
  
  &lt;input type="button" id="Calculate" value="Calculate" 
  onclick="calcform()" /&gt;&lt;input type="reset" id="reset" value=" Clear "/&gt;&lt;/tr&gt;
  
  &lt;br/&gt;&lt;tr&gt;&lt;td&gt;&lt;h4&gt;&lt;strong&gt;Option 1&lt;/strong&gt;&lt;/h4&gt;&lt;br/&gt;
  
  &lt;h4&gt;Leasing Fee (75% of one month's rent):&lt;br /&gt; 
  &lt;input type="text" id="result1" value="" size="40" /&gt;&lt;/h4&gt;&lt;br/&gt; 
  
  &lt;h4&gt;Monthly Management Fee per unit (Fixed[enter link description here][1] $69 x 12 months):&lt;br /&gt; 
  &lt;input type="text" id="number3" value="828" size="40" /&gt;&lt;/h4&gt;&lt;br/&gt; 
  
  &lt;h4&gt;Monthly Management Fee all units:&lt;br /&gt; 
  &lt;input type="text" id="result2" value="" size="40" /&gt;&lt;/h4&gt;&lt;br/&gt;
  &lt;/form&gt; &lt;/table&gt;
  </code></pre>
  
  <p>You can see this at dev1.beastlyweb.com.  I've also uploaded the Excel spreadsheet there that contains the calculations the client wants replicated online.</p>