View Full Version : Dynamic Select Field?

10-28-2006, 06:55 AM
Hi there,

I've run into a snag and would really appreciate some help!

I have many colors/sizes of a particular product. Each item has a different SKU number, and each item has a different ProductID number.

For example:

ID Product Name ProductSKU Color Size
3345 Product-A 24062-19 Green 8
3346 Product-A 24062-20 Green 10
3347 Product-A 24063-19 Red 8
3348 Product-A 24063-20 Red 10

The customer should only see the product once on the page, and then be able to select the color and size. I'm trying to figure out how to grab the correct SKU number depending on the color/size the customer chooses.

I know I can use something like:

<select name="color" onchange="this.form['product_no'].value=this.value">
<option>Select a Color...</option>
<option value="3345">Green</option>
<option value="3347">Red</option>

But, you can see the problem. 3346 is also green, but just a different size. Is there a way to pull the correct id number upon selecting both the size *and* color?

10-28-2006, 11:45 PM
I cannot offer any specific coding to do this, but here are some thoughts -

Typically, to keep the form code generic, there would only be codes/values for the sizes and colors and these would be sent to the server when the form/order is submitted. The order processing code would determine the actual product ID/SKU...

If you do want to do this in the browser, it would be possible to create a javascript function that is called using the onchange event that would look at the current color option selected and the current size option selected and determine the correct ID.