I have a form with multiple select boxes. When the user selects from the last select box it trigers an onchange event. How do I trigger the onchange event.
Here are my three select boxes. It doesn’t work this way. Could this be a syntax issue?
[code=html]<label for=’Color_field’>Color</label>:
<select id=”Color” name=”Color”>n<option selected>Please select an item</option>
<option>Color Both Sides</option>
<option>Color Front No Back</option>
<option>Color Front B&W Back</option>
</select><br>
<label for=’Size_field’>Size</label>:
<select id=”Size” name=”Size”>n<option selected>Please select an item</option>
<option>2×3.5</option>
<option>3.35×2.17</option>
<option>Color Front B&W Back</option>
</select><br>
<label for=’Quantity_field’>Quantity</label>:
<select id=”Quantity” name=”Quantity” onchange=”window.location.href=’http://imagews.com/index.php?option=com_virtuemart&page=shop.product_details&flypage=flypage.tpl&product_id=20&Color=’+document.addtocart.Color.options[document.addtocart.Color.selectedIndex].value’&Size=’+document.addtocart.Size.options[document.addtocart.Size.selectedIndex].value’&Quantity)=’+document.addtocart.Quantity.options[document.addtocart.Quantity.selectedIndex].value”><option selected>Please select an item</option>
<option>5000</option>
<option>100</option>
<option>250</option>
<option>500</option>
<option>1000</option>
<option>2500</option>
</select><br>
It works this way, but in the string the different selectedIndex values do not have a variable for the $_GET super global in php. In the browser url it displays as
Color Both Sides2x3.5500 instead of Color=Color Both Sides&Size=2×3.5&Quantity=500. I have another possible way, but I think there is a sytax problem when I use the equal sign.
Here it is the javascript code.
Doesn’t work.
[code=html]
onchange=”window.location.href=’http://imagews.com/index.php?option=com_virtuemart&page=shop.product_details&flypage=flypage.tpl&product_id=20&’document.addtocart.getElementById(Color )’=’+document.addtocart.Color.options[document.addtocart.Color.selectedIndex]’&’document.addtocart.getElementById(Size )’=’+document.addtocart.Size.options[document.addtocart.Size.selectedIndex].value’&’document.addtocart.getElementById(Quantity )’=’+document.addtocart.Quantity.options[document.addtocart.Quantity.selectedIndex].value”
Works.
[code=html]<select id=”Quantity” name=”Quantity” onchange=”window.location.href=’http://imagews.com/index.php?option=com_virtuemart&page=shop.product_details&flypage=flypage.tpl&product_id=20&’+document.addtocart.Color.options[document.addtocart.Color.selectedIndex]+document.addtocart.Size.options[document.addtocart.Size.selectedIndex].value+document.addtocart.Quantity.options[document.addtocart.Quantity.selectedIndex].value”><option selected>Please select an item</option>
<option>5000</option>
<option>100</option>
<option>250</option>
<option>500</option>
<option>1000</option>
<option>2500</option>
</select><br>
Can anyone help? I need to get this done.