I am trying to make an order page to add multiple products through javascript. PHP/HTML code is:
<?php $module_row = 0; ?>
<tbody id="module-row<?php echo $module_row; ?>">
<tr>
<td><select name="prod[]"><?php foreach ($products as $product) { ?><option value="<?php echo $product['ID']; ?>"><?php echo $product['name']; ?></option></td><td><a onClick="addProd();">Add New</a></td>
</tr></tbody>
<?php $module_row++; ?>
And my Javascript code is:
var module_row = <?php echo $module_row; ?>;
function addProd() {
html = '<tbody id="module-row' + module_row + '">';
html += ' <tr>';
html += ' <td class="left"><select name="prod[]">';
<?php foreach ($products as $product) { ?>
html += ' <option value="<?php echo $product['ID']; ?>"><?php echo $product['name']; ?></option>';
<?php } ?>
html += ' </select></td></tr></tbody>';
$('#module tfoot').before(html);
module_row++;
Now I want to to show products array in later added rows to show products dropdown with out the products selected above. I have checked a lot of forums but could not find a solution to get the above selected value of dropdown. Any idea about this?