title: Dynamic Dropdown List from SQL with JS
body: <p>Please help, I have a dynamic JS table, so you can add and delete rows by clicking a button. One field that I need to add within the row is a select box, no problem so for and I use the following:</p>
  
  <pre><code>var cell2 = row.insertCell(1);
  var sel = document.createElement('select');
  sel.name = 'selRow' + rowCount;
  sel.options[0] = new Option('text zero', 'value0');
  sel.options[1] = new Option('text one', 'value1');
  cell2.appendChild(sel);
  </code></pre>
  
  <p>So the above creates a select box, named based on the row ID using rowCount. Where I’m stuck is I need to dynamically populate the options, I can do this with php using the following, but it is linking the JS and PHP that I’m stuck on:</p>
  
  <pre><code>$getProd_sql = 'SELECT * FROM products';
  $getProd = mysql_query($getProd_sql);                 
  $prov = "&lt;select name=\"product\" id=\"product\" onChange=\"testajaxprod();\"&gt;";
  $prov .= " &lt;option value=\"0\" selected=\"selected\"&gt;Select Product&lt;/option&gt;";
          while($row = mysql_fetch_array($getProd))
          {
              $prov .= "&lt;option value=\"$row[product_id]\"&gt;$row[product_name]&lt;/option&gt;";
          }
  $prov .= "&lt;/select&gt;";
  </code></pre>
  
  <p>Your help is very much appreciated.</p>
  
  <p>Thanks,
  B.</p>