title: How to find prime numbers in entered number range
body: <p>I'm just trying to find prime numbers of an entered range of numbers. I have no clue how to calculate finding primes. I need to add them to an array and output the array after. I put a placeholder for the calculation... I just can't seem to figure out how find the primes.</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"&gt;
  
  &lt;html&gt;
  
      &lt;head&gt;
          &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
  
          &lt;title&gt;LeapYears&lt;/title&gt;
  
          &lt;script type="text/javascript"&gt;
          /* &lt;![CDATA[ */
  
          function calcPrimeNumber(){
  
                  var beginNum = document.numbers.firstNum.value;
                  var endNum = document.numbers.secondNum.value;
                  var primeNumbs = new Array();
  
  
                  var ctr = 0;
                  while (beginNum &lt;= endNum){ //throwaway
                      if ((beginNum % beginNum == 0) &amp;&amp; (beginNum % 1 == 0)){
                          primeNumbs[ctr] = beginNum;
                          ++ctr;
                      }
  
                      ++beginNum;
                  }
  
                  if (primeNumbs == 0){
                      window.alert("There were no leap years within the range.");
                  }
  
                  else {
                      outputPrimeNums(primeNumbs);
                  }
  
          }
  
          function outputPrimeNums(primes){
              document.write("&lt;h2&gt;Prime Numbers&lt;/h2&gt;");
              for (i=0;i&lt;primes.length;i++){
                      document.write(primes[i] + "&lt;br/&gt;");
                  }
  
          }
  
  
          /* ]]&gt; */
          &lt;/script&gt;
  
  
      &lt;/head&gt;
  
  
      &lt;body&gt;
          &lt;form name="numbers"&gt;
  
              Beginning Number: &lt;input type="text" name="firstNum" /&gt; End Number: &lt;input type="text" name="secondNum" /&gt; 
              &lt;input type="button" value="Find Prime Numbers" onclick="calcPrimeNumber()" /&gt;
  
          &lt;/form&gt;
  
      &lt;/body&gt;
  
  
  &lt;/html&gt;
  </code></pre>