Ryflex Posted October 2, 2010 Share Posted October 2, 2010 Hi all, I have a Dropdown menu and I want to have an onclick event in it. So basicaly there's value 1 and value 2 and when I select value 2 the page goes to the link behind it. I guess this is javascript and I'm a total noob in javascript so I hope anyone can help me out. Thnx Ryflex Link to comment https://forums.phpfreaks.com/topic/215010-dropdown-onclick/ Share on other sites More sharing options...
JTallis Posted October 2, 2010 Share Posted October 2, 2010 Use an onchange event. Maybe... onchange="doThis(this.value)" within your dropdown. What do you mean behind it? The way I would do it, unless there is a better method.. is have two values in the drop down - "Value1" and "Value2" Then within the head tags, create a function.. <script type="text/javascript"> function doThis(VALUE) { if(VALUE == "Value2") { window.location = "URL"; } } </script> Replace URL with the url to go to. This may work. Link to comment https://forums.phpfreaks.com/topic/215010-dropdown-onclick/#findComment-1118427 Share on other sites More sharing options...
Ryflex Posted October 3, 2010 Author Share Posted October 3, 2010 @JTallis What I mean is that I have say 10 cities named in the Dropdown list each with a number value. When I select say city 2 I need the script to go to another page which uses the value of that city in a php $_POST variable. Thnx Ryflex Link to comment https://forums.phpfreaks.com/topic/215010-dropdown-onclick/#findComment-1118499 Share on other sites More sharing options...
JTallis Posted October 3, 2010 Share Posted October 3, 2010 oh I see. I'm not sure, it's something I'd like too. Though I think you can pass the value into the redirect URL in the JS Function, and then use a GET. Though that would allow someone to manually type it in. Link to comment https://forums.phpfreaks.com/topic/215010-dropdown-onclick/#findComment-1118508 Share on other sites More sharing options...
Ryflex Posted October 3, 2010 Author Share Posted October 3, 2010 @JTallis The point is indeed that with a GET people could input just in the adressbar. That's why I'm looking for something with POST. Ryflex Link to comment https://forums.phpfreaks.com/topic/215010-dropdown-onclick/#findComment-1118510 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.