I have code on my order page that I borrowed from somewhere. It works, but I don't know why. It's at http://www.thetoffeehouse.com/order.asp.
e.g. If you choose Red for the Three Pound Tin, hit Add to Cart, it shows up in the next screen as red, with the right part number. However, this is the code behind that part of the form:
<font size=2 face="Verdana">Color: <SELECT Name='P1'> <Option selected Value =Gold>Gold</Option> <Option Value =Red>Red</Option> </SELECT> <input type=hidden name='t1' value='d-Color;Red:partno=DSTIN3Red;Gold:partno=DSTIN3Gold;'>
How does it know how to get the right part number for the right selection when it looks like there's no connection between the two, and the part number items are in a different order than the SELECT items?
I'm sure it's a simple answer, but I can't firgure it out.
If you need more code, let me know. But you probably can see it yourself behind the page.
Curious about this form code
that's a typical shopping-cart style script. what happens is that when the form is submitted, the form handler looks at the value given by 'P1' and, if you look closely, there are 3 parts to the hidden input tag value separated by semicolons. the first tells what the variant is ('d-Color'), the next two give all options (in this case, red and gold). if the 'P1' matches 'Red', that partno is forwarded by the handler. each shopping cart has their own exact technique to do this, but they all have the same general ideas behind them