title: Javascript: Array is not working with Form
body: <p>I currently am doing a a program that will show the primes and palindromic primes in a new window from a range a user inputs, here is my code so far:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset = "utf-8"&gt;
      &lt;title&gt; 9.25 Excercise &lt;/title&gt;
      &lt;script type = "text/javascript"&gt;
          &lt;!-- Begin
          var arrayLength = (parseInt(form.endNum.value))-(parseInt(form.startNum.value));
          var num=new Array(arrayLength);
          var number1=parseInt(form.startNum.value);
  
          for (var y=0; y&lt;arrayLength; y++){
              num[y] = number1;
              number1++;
              }
  
          function calculate1(form) {
          var newWindow = window.open("","Test","width=300,height=300,scrollbars=1,resizable=1");
          newWindow.document.write("Prime: &lt;br&gt; &lt;br&gt;");
          for (y=0; y&lt;arrayLength; y++)
              if (num[y] == 1) {
                  newWindow.document.write(num[y]);
              }
              for (var i=2;i&lt;num[y];i++) {
                  if (num[y] % i == 0) {
                      var prime="yes";
                      newWindow.document.write(num[y]);
                      break;
                  }
              if (num[y] % i != 0) var prime="no";
              }
          }
          // End --&gt;
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;  
      &lt;form name=form&gt;
          This Program finds Prime numbers and Palindromic numbers between two integers.&lt;br&gt;
          Maximum range between the integers is 999.&lt;br&gt;
          &lt;hr /&gt;
          Starting Value (&gt;0):  &lt;input type="number" name="startNum" min="1" max="99999"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ending Value (&lt;= 99999): &lt;input type="number" name="endNum" min="1" max="99999"&gt; &lt;br&gt;  &lt;br&gt;
          &lt;input type=button value="Find Primes" onClick="calculate1(this.form)"&gt;
          &lt;input type=button value="Find Palindromic Primes Only" onClick="calculate2(this.form)"&gt;
          &lt;input type=button value="Find Both" onClick="calculate3(this.form)"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>The problem I am having is that the numbers are not showing up in the window, and I don't know if its because of the array not working properly or I'm not writing to the window correctly. Currently, I can get it to show the number 1, but that is it. The data I want is also going into the array. The only issue is getting the prime numbers, other than 1 to show in the window, without breaking it. Note that this is a work in progress and currently I just need help showing the primes in the new window.</p>
  
  <p>Edit: added more info about the problem</p>