Hi,
Fogive me if my subject line doesnt really explain what I am doing well enough...but here is the problem. I am trying to build a very simple shopping cart. I want to select products by using a pull down and hitting submit. I am populating the pulldown using values from a MySQL query. Here is the code:
<body>
<form name="form1">
<input type="hidden" name="productid" />
<input type="hidden" name="command" />
</form>
<div align="center">
<h1 align="center">Products</h1><br />
<table border="0" cellpadding="2px" width="600px">
<select name="gfd" id="gfd">
<?
$result=mysql_query("select * from products");
while($row=mysql_fetch_array($result)){
?>
<option value=<?=$row['serial']?>><?=$row['name']?></option>
<?
}
?>
</select>
<input type="button" value="Add to Cart" onclick="addtocart(<?=$row['serial']?>)" />
</td>
</tr>
<tr><td colspan="2"><hr size="1" /></td>
</table>
</div>
</body>
My issue is each product in the database as a name, price, and serial number and I need to get the value of the selected items SERIAL outside of the loop and into the onclick line.
<input type="button" value="Add to Cart" onclick="addtocart(<?=$row['serial']?>)" />
What is the best way to have the user select a product from the pulldown and have the serial value of that product in the database to be reported outside of the loop so that I have that value be passed in onclick?
Hope I explained well. Thank you in advance for any advice.....