title: Javascript function refuses to calculate variables
body: <p>I am trying to allow Javascript to calculate a function of several different variables and results. Honestly I've spent the last two days working on it and literally have no idea where to go from here. My code as follows:</p>
  
  <pre><code>&lt;html&gt;
  &lt;title&gt;Calculate Your Monthly Payments&lt;/title&gt; 
          &lt;script language = "JavaScript"&gt; 
              function Calc(){ 
              var a, res;             
              a = parseFloat(document.monthly.form.value); 
              res1 = a/1000;
              res2 = a/500;
              res3 = a/300;
  
              if(document.monthly.payments[1].style.visibility = "visible" )
                  window.alert("Your monthly repayments have been estimaded to be £" + res1);
  
              else if(document.monthly.payments[2].style.visibility = "visible" )
                  window.alert("Your monthly repayments have been estimaded to be £ " + res2);
  
              else(document.monthly.payments[3].style.visibility = "visible" )
                  window.alert("Your monthly repayments have been estimaded to be £ " + res3);
              } 
  
          &lt;/script&gt; 
  &lt;/head&gt; 
  
  
  &lt;div id="container"&gt;
  
          &lt;h2&gt;Calculate Your Monthly Payments&lt;/h2&gt; 
          &lt;h4&gt;Please fill in the form below&lt;/h4&gt;
           &lt;form name = "monthly"&gt; 
             How much are you borrowing? (£): &lt;br&gt;&lt;input name = "form" type = "text" size = 10 id="textarea"&gt; &lt;br&gt;&lt;br&gt;
  
                  Mortgage Type: &lt;br&gt;
                  &lt;select name = "payments"&gt;
                    &lt;option value="" selected&gt;Please Select &lt;/option&gt;
                    &lt;option value="1"&gt;Mortgage 2.19% fixed until 2015 &lt;/option&gt;
                    &lt;option value="2"&gt;Mortgage 3.17% fixed until 2017 &lt;/option&gt;
                    &lt;option value="3"&gt;Mortgage 3.18% fixed until 2024 &lt;/option&gt;
                  &lt;/select&gt;
                  &lt;br&gt;&lt;br&gt;                
  
             &lt;input type = "button" value = "Calculate Payments! " onclick = "Calc();"&gt; 
          &lt;/form&gt;
  &lt;/div&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have been trying to have the event being displayed as a popup which says <br><br> "Your Monthly Payment is ...".<br><br>
  The equation I want to implement should work as whatever you enter is divided by what you choose.</p>
  
  <p>If a is selected then as an example it will be divided by 1000 <br>
  if b is selected then as an example it will be divided by 500 <br>
  and if c is selected then as an example it will be divided by 300. <br></p>
  
  <p><strong>However.. none of this works.</strong></p>
  
  <p>I have been going though the code over and over and have made it work, though only partially as the event then displays two pop-ups. First being option value 1 and second replacing it after being click with option value 2.</p>
  
  <p><strong>The Problem is that:</strong></p>
  
  <p>Upon viewing in a browser and clicking on the "Calculate Payments" button nothing happens. Why is this?</p>
  
  <hr>
  
  <p>I hope I made this clear since I'm a bit rough with English but I would appreciate any help whatsoever.</p>