title: how to dynamically render multiple form elements using for loop
body: <p>i want to display a certain number of input tags for a form; this should depend on how many items a user dynamically selects that they want.  </p>
  
  <p>for example, if a user says they want 3 items. i want to display 3 input bars.</p>
  
  <p>i am not clear of the best way to proceed with this. for example, i am able to determine how many items they select from the select options:</p>
  
  <pre><code> $(".howmany").change(function(){
  
              var value  = $(this).val(); 
  
  }
  </code></pre>
  
  <p>but what is the correct way to proceed thereafter; do i dynamically render the exact number of input tags selected using a <strong>for each</strong>: or pre-display (but hide) all of the input tags and only show the exact number of input tags requested.</p>
  
  <p>i would appreciate an example of how its been done . at the moment i am only able to hide the entire area. eg: </p>
  
  <pre><code>var requests =  $("#howmany").val();
  
          if (reqeusts &lt; 1){
              $('#reqeusts').hide();
          }
          else {
             $('#reqeusts').show();
         }
  </code></pre>
  
  <p>but i obviously need to be able to show individual form tags accordingly to the number the user selected. </p>
  
  <p>hi again,  i want to thank everyone for their answers.</p>
  
  <p>i deeply sorry, but i forgot to mention that the reason for the confusion is that the values for the imput are dynamically fed from an array function. </p>
  
  <pre><code>public function arrayValues() 
                      {
                          return $selection = array(
                              '0' =&gt; 'none' ,' 1' =&gt; '1 item' ,' 2' =&gt; '2 item' ,' 3' =&gt;' 3 item' );
                      } 
  </code></pre>
  
  <p>i then need to render one of the below imput select tags for each number of items selected.          </p>
  
  <pre><code>                    &lt;?php echo ' 
                      &lt;select id="howmany" name="items[howmany]"  /&gt;'; 
  
  
                      foreach ($arrayValues as $key =&gt; $value)
                      {       
                          echo '&lt;option value="' . $key .'"&gt;' . $value . '&lt;/option&gt;';
                      }
                      echo'&lt;/select&gt;'; 
                      ?&gt;
  </code></pre>