So I have this piece of code I've been tinkering with. The Jquery is modified from somewhere else. I'm wanting to be able to add products on this page (which currently works)... but the part im struggling with is I then submitted ALL of that data to MySql through a submit button.
I've tried playing around with a few arrays / loops but so far I have drawn a blank. Can anyone help?
<html>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
var currentItem = 1;
$('#addnew').click(function() {
currentItem++;
$('#items').val(currentItem);
var strToAdd = '<br>product: <select name="product'+currentItem+'" id="product'+currentItem+'" ><option value="aclt">Tobacco</option><option value="aed">Energy Drink</option></select> nicotine: <select name="nicotine'+currentItem+'" id="nicotine'+currentItem+'"> <option value="3">3mg</option><option value="6">6mg</option><option value="12">12mg</option></select> Qty:<input name="qty'+currentItem+'" id="qty'+currentItem+'" type="text" />';
$('#data').append(strToAdd);
});
});
//]]>
</script>
<form method="POST" action="invoicereg.php" id="data" name="sub">
product:
<select name="'product1'" id="product1" >
<option value="aclt">Tobacco</option>
<option value="aed">Energy Drink</option>
</select>
nicotine:
<select name="nicotine1" id="nicotine1">
<option value="3">3mg</option>
<option value="6">6mg</option>
<option value="12">12mg</option>
</select>
Qty:<input type="text" id="qty" name="qty"></input><br>
</form>
<button type="submit" form="data">SUBMIT</button>
<input type="button" id="addnew" name="addnew" value="Add new item" />
<input type="hidden" id="items" name="items" value="1" />
</html>