As you can see the product_id get passed to the javascript, but it is essential that I get the price and color id passed along… Is that possible, and if yes…HOW???
The multiple selections should then be passed to the JavaScript instead of just the one so that rather than just getting the selectedIndex you’d need to loop through the array and see which are selected.
The Color and price is part of the product as the product_id. Imagine that I have a bunch of products in a loop, and the quantity is a option for each product…
So mayby if there is a way to comma seperate the ids in the selectname like this:
Unless there’s some compelling reason to do something mucky like build a comma delimited string as the name, I wouldn’t.
A function can take multiple arguments.
function Update(selectElement, color, price) {
...
}
Then you could just embed the values into the html.
Update(this, ‘red’, 5.99);
But…is there a reason why you aren’t just using a form(s)? If want the form to submit automatically when the user makes a selection from a menu, you can do that while still using a form. Then you don’t require javascript for it to work.
onchange=“this.form.submit()”
And then just make some input elements for the color and price.
I’m not sure how you’re handling this, but thought I’d mention that you should make sure the user doesn’t change the price. So check it against a list, or create some kind of numerical id that maps to a specific combination of name, color, and price, that only you know about, and just use that as the id in the html.