title: Adding a PHP function using JQuery every time a user clicks add another select field button
body: <p>I'm trying to add a php function called <code>select()</code> using jquery every time a user clicks on add another select field button is it possible to do this or is there a better way a user can add the php function <code>select()</code> every time a user clicks add another select field?</p>
  
  <p>JQuery (plugins.php)</p>
  
  <pre><code>$(document).ready(function(){
      var max_fields = 10;
      var x = 1;
  
      $('.add-another').click(function(e){
          e.preventDefault();
          e.stopPropagation();    
  
          if(x &lt; max_fields){
              x++;
              $(this).closest('li').find('div:eq(3)').append('&lt;?php echo select(); ?&gt;');  
          }
  
      });
  });
  </code></pre>
  
  <p>PHP (input-fields.php)</p>
  
  <pre><code>function select(){
      $select = '';
      $select .= '&lt;select name="select[]" class="title"&gt;';
  
      foreach(select_options() as $option){
          $select .= '&lt;option value="'. $option . '"&gt;' . $option . '&lt;/option&gt;';
      }
  
      return $select;
  }
  </code></pre>