Fire Dragon Posted February 7, 2006 Share Posted February 7, 2006 I tried make dropdown list to my website,I success create menu itself,but I have problems to create menu's options to links. <form><select name="R/S 252-386"><OPTION> 252 <OPTION> 253<OPTION> 254 </select> Here was my code.I can't find how change options to links.I saw one JS example,but after you select you must press button "GO!" etc.I want code,what sends you immediately to next page,after you selected something.Do I need JS for this,or can I create it only with HTML?Thanks. Link to comment Share on other sites More sharing options...
aspnetguy Posted February 7, 2006 Share Posted February 7, 2006 I tried make dropdown list to my website,I success create menu itself,but I have problems to create menu's options to links.<form><select name="R/S 252-386"><OPTION> 252 <OPTION> 253<OPTION> 254 </select> Here was my code.I can't find how change options to links.I saw one JS example,but after you select you must press button "GO!" etc.I want code,what sends you immediately to next page,after you selected something.Do I need JS for this,or can I create it only with HTML?Thanks. <{POST_SNAPBACK}> thats because you can't...you need to use the onchange event of the list and redirect based on the slected option Link to comment Share on other sites More sharing options...
Fire Dragon Posted February 7, 2006 Author Share Posted February 7, 2006 Nevermind.I just found generator for this. Link to comment Share on other sites More sharing options...
aspnetguy Posted February 7, 2006 Share Posted February 7, 2006 just use this <html><head> <title>test</title></head><body><select onchange="window.location=this[this.selectedIndex].value"> <option value="#">Choose a serach engine</option> <option value="http://www.google.ca">Google</option> <option value="http://www.msn.ca">MSN</option> <option value="http://www.askjeeves.com">Ask Jeeves</option></select></body></html> Link to comment Share on other sites More sharing options...
Eric Posted February 7, 2006 Share Posted February 7, 2006 just use this<html><head> <title>test</title></head><body><select onchange="window.location=this[this.selectedIndex].value"> <option value="#">Choose a serach engine</option> <option value="http://www.google.ca">Google</option> <option value="http://www.msn.ca">MSN</option> <option value="http://www.askjeeves.com">Ask Jeeves</option></select></body></html> <{POST_SNAPBACK}> That <select onchange="window.location=this[this.selectedIndex].value"> is pretty nifty.Although I haven't used forms as a means of linking in a very long time, I used to use <select name="dropdown" onchange="location.href=(form.dropdown.options[form.dropdown.selectedIndex].value)">But your way seems more efficiant as it uses slightly less code Link to comment Share on other sites More sharing options...
aspnetguy Posted February 8, 2006 Share Posted February 8, 2006 That <select onchange="window.location=this[this.selectedIndex].value"> is pretty nifty.Although I haven't used forms as a means of linking in a very long time, I used to use <select name="dropdown" onchange="location.href=(form.dropdown.options[form.dropdown.selectedIndex].value)">But your way seems more efficiant as it uses slightly less code <{POST_SNAPBACK}> I didn't use the 'this' object for a long time but it saves many headaches once you master it...it is an instance of the current object you are working with.It is great when writing unobtrusive JS. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now