Simultaneously Changing Multiple Fields Using a Select Menu

Here is an example of how to change multiple fields in the form tag for adding items to the shopping cart, using only a select menu.


SimpleCart Example (Change more than one field in the item variable at once)

This example shows an easy way to change all fields in the item variable at once. It is a really powerful "trick".

[Use of the item variable in a select box instead of as a hidden var]


qty:

<form action="http://www.cartserver.com/sc/cart.cgi" method="post">
<select name="item">
<option value="s-8882^XYZ^Pants 2XL^15.00^op2"> 2XL Pants </option>
<option value="s-8882^ABC^Pants 3XL^17.00^op2"> Pants 3XL (or any text) </option>
<option value="s-8882^123^Pants 4XL^19.00^op2"> Pants 4XL $19/pair </option>
</select>
<br />
qty: <input name="op2" size="2" value="1" />
<br />
<select name="op1">
<option> Black </option>
<option> Brown </option>
<option> Blue </option>
</select>
<br />
<input type="image" name="add" src="/images/addtocart.gif" />
</form>

Note that the single select box above changes the partnumber field, the description field, the price, and the "per item" shipping field all at once. Having the item var be a select instead of hidden can add alot of functionality.


Copyright. All rights reserved. Americart - 2011