title: Creating inputs in function, or any other method (Javascript)
body: <p>I'm trying to make something that makes it easier to write out a matrix/matrices.
  You start with getting two number inputs for the dimensions of the matrix. And after that you "submit" the numbers and out comes several input boxes. </p>
  
  <p>How do you write this code? Is it possible to do it in another function?</p>
  
  <p>I was thinking of having the "submit" button have a validification to see if numbers are real, and if they are the function continues with for loops on how to "write" out the number boxes.</p>
  
  <p>This is what I got right now: </p>
  
  <pre><code>function validate(){
      var num;
      num = document.getElementById("numberbox").value;
  
      var myForm = document.getElementById('payForm'); // 
      while(myForm.hasChildNodes()){
          myForm.removeChild(myForm.firstChild);
      }
  
      myForm = document.createElement("form");
      myForm.setAttribute("method","post");
      myForm.setAttribute("action","processChecking.php");
  
      if(isNaN(num) || num&lt;1){
          document.getElementById("output").innerHTML = "invalid number!";
          document.getElementById("numberbox").value = '';
      } else {
          document.getElementById("output").innerHTML = "number validated!";
          array(num);
          for (var i = 0; i &lt;= num; i++) {
              var input = document.createElement('input');
              input.type = 'text';
              input.name = 'myInput_' + i;
              input.id = 'myInput_' + i;
              myForm.appendChild(input);
          }
      }          
  }
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;body&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;p&gt;
                      Enter number for how many number boxes you want:&lt;br&gt;        
                      &lt;input id="numberbox" type="number"&gt;        
                      &lt;button type="button" onclick="validate()"&gt;Validate&lt;/button&gt;
                      &lt;br&gt;
                      &lt;p id="output"&gt;&lt;/p&gt;
                      &lt;br&gt;
                  &lt;/p&gt;
              &lt;/td&gt;
              &lt;td style="text-align:right;"&gt;
                  &lt;p id="payForm"&gt;&lt;/p&gt;   
              &lt;/td&gt;
          &lt;/tr&gt; 
      &lt;/table&gt;
  &lt;/body&gt;
  </code></pre>