| | |
How to make javascript form autochange - "Onchange"?
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2005
Posts: 3
Reputation:
Solved Threads: 0
Hello, I have this code:
I need to make it so as soon as you click that select box, it loads the url (value)... if anyone can help me that would be great!
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<select name="product" class="buy"> <option value="products.php" selected>Select Term</option> <option value="products.php?item=1&term=1">2 Month</option> <option value="products.php?item=1&term=3">3 Months</option> <option value="products.php?item=1&term=6">4 Months</option> <option value="products.php?item=1&term=12">5 Months </option> </select>
I need to make it so as soon as you click that select box, it loads the url (value)... if anyone can help me that would be great!
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Loads it where?
Look at some of the code in this article: Creating an HTML "ComboBox" control
It demonstrates all the techniques you'll need to reference Select/Option controls, retrieve their values, and copy them into other controls.
Look at some of the code in this article: Creating an HTML "ComboBox" control
It demonstrates all the techniques you'll need to reference Select/Option controls, retrieve their values, and copy them into other controls.
•
•
Join Date: May 2005
Posts: 3
Reputation:
Solved Threads: 0
Thanks for your help.Here's my code again:
When they click the "2 Month" value, it will load http://www.mydomain.com/products.php?item=1&term=1. Do you see what I'm trying to do? Thanks
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<select name="product" class="buy"> <option value="products.php" selected>Select Term</option> <option value="products.php?item=1&term=1">2 Month</option> <option value="products.php?item=1&term=3">3 Months</option> <option value="products.php?item=1&term=6">4 Months</option> <option value="products.php?item=1&term=12">5 Months </option> </select>
When they click the "2 Month" value, it will load http://www.mydomain.com/products.php?item=1&term=1. Do you see what I'm trying to do? Thanks
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Sure. Add on onChange handler:
Code the mySelect function in the head/script section:
Some variation of that ought to do the trick.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<select name = "product" class="buy" onChange="JavaScript:mySelect(this);">
Code the mySelect function in the head/script section:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function mySelect(x) { window.location.href = "http://www.your_domain.com/" + x.options[x.selectedIndex].value; }
Some variation of that ought to do the trick.
![]() |
Similar Threads
- Make Background Form is Transparent (VB.NET)
- javascript works in IE but not working in firefox (JavaScript / DHTML / AJAX)
- Error while trying the update query (ASP)
- Check existing users in the database (ASP)
- Javascript, Form fields validation and submit (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: What is wrong wtih my css?
- Next Thread: Javascript form managment on the fly!
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array browser captcha captchaformproblem cart child class close codes column css date debugger decimal dependent design disablefirebug dom download editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index java javascript javascripthelp2020 jquery jsf jsp jump libcurl listbox maps masterpage math media menu mp4 object onerror onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming prototype rated rating redirect safari scale scriptlets scroll search security select software star starrating stars synchronous toggle unicode variables w3c web webservice \n






