X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   How to reference a drop down (https://forum.x-cart.com/showthread.php?t=18565)

phil_ 12-10-2005 04:47 AM

How to reference a drop down
 
Hi,

I hope someone out there can help. I want to create a select drop down such as:

<select name="custom_drop_down">
<option selected value="one">Select your option...</option>
<option value="two">Option 1</option>
<option value="three">Option 2</option>
</select>

and then pass over whatever the selected option value is (i.e the string one, two or three) as a smarty variable in a from. How can I do this assignment?

Your help is greatly appreicated.

Thanks, Philip.

shan 12-10-2005 10:05 AM

maybe explain a bit more

phil_ 12-10-2005 10:20 AM

ok, I worked it out. You can just do it simply with javascript and an onchange event.

In javascript functions:

function set_parameter(){
document.formname.param_to_pass.value = document.formname.custom_drop_down.options[document.formname.custom_drop_down.selectedIndex].value;
}

Then in your form:

<select name="custom_drop_down" onchange="set_parameter()">
<option selected value="one">Select your option...</option>
<option value="two">Option 1</option>
<option value="three">Option 2</option>
</select>

<input type="hidden" name="param_to_pass" value="one">

now on changing the drop down, it updates the value of param_to_pass to whatever the selected option value is.

Philip.


All times are GMT -8. The time now is 03:01 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.