Russia Posted November 8, 2009 Share Posted November 8, 2009 I would like this code to auto link after it is selected, that means when u choose an option in the dropdown it links you without having to click any buttons. It is for a pagination for the limit of how many to show on each page. <font color="black">Show per page</font> <select onchange="setLocation(this.value)"> <option value="?limit=9">9</option> <option value="?limit=15">15</option> <option value="?limit=30">30</option> <option value="?limit=all"> All </option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/180719-dropdown-link/ Share on other sites More sharing options...
ngreenwood6 Posted November 8, 2009 Share Posted November 8, 2009 Can you explain a little clearer what you are trying to do? I do not get what you mean this: when u choose an option in the dropdown it links you without having to click any buttons Quote Link to comment https://forums.phpfreaks.com/topic/180719-dropdown-link/#findComment-953592 Share on other sites More sharing options...
Russia Posted November 8, 2009 Author Share Posted November 8, 2009 Basically this: <script language="JavaScript"> function loadPage(list) { location.href=list.options[list.selectedIndex].value } </script> <form> <select name="file" size="1" onchange="loadPage(this.form.elements[0])" target="_parent._top" <option value="?limit=9">9</option> <option value="?limit=15">15</option> <option value="?limit=30">30</option> <option value="?limit=all">All</option> </select> </form> Quote Link to comment https://forums.phpfreaks.com/topic/180719-dropdown-link/#findComment-953622 Share on other sites More sharing options...
ngreenwood6 Posted November 9, 2009 Share Posted November 9, 2009 I think this is what you are looking for but you still didnt explain it any better you just said basically this with an example that still doesnt explain what you are trying to do. I assume you are trying to submit the page on change and pass the limit to the page so try this: <form> <select name="limit" size="1" onchange="this.form.submit();"> <option value="9">9</option> <option value="15">15</option> <option value="30">30</option> <option value="all">All</option> </select> </form> So basically that will submit this form and it will put a get variable in the url. so in this case the url will look like http://yourwebsite.com?limit=9 if you were to select the first option. is that what you were looking for? Quote Link to comment https://forums.phpfreaks.com/topic/180719-dropdown-link/#findComment-953922 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.