Lamez Posted December 18, 2007 Share Posted December 18, 2007 Alright, once again sorry about my last post. Now I want to make a drop down list in html, which I have done, and I set the values from 0 - 5 as my action can I make it where it is is value 1 redirect to another page, and the same with the other values, I am not sure on how to go about this. I know I am going to have to write a IF statement. If you start the code I a can finish it. thanks again! ??? Quote Link to comment https://forums.phpfreaks.com/topic/82137-solved-one-more-question-how-to/ Share on other sites More sharing options...
tibberous Posted December 18, 2007 Share Posted December 18, 2007 Are you trying to do it when the form is submitted, or when it is changed with javascript? If you make a lookup array you don't actually need an if either way you write it. Quote Link to comment https://forums.phpfreaks.com/topic/82137-solved-one-more-question-how-to/#findComment-417388 Share on other sites More sharing options...
Lamez Posted December 18, 2007 Author Share Posted December 18, 2007 ya like here is my drop down box: <form id="sort" name="sort" method="post" action="action.php"> <label> <select name="select"> <option value="#">Sort By...</option> <option value="0">All Members</option> <option value="1">Username</option> <option value="2">Last Online</option> <option value="3">Online Only</option> <option value="4">Offline Only</option> </select> </label> </form> say they click All Members it the action will redirect them to the right page. Quote Link to comment https://forums.phpfreaks.com/topic/82137-solved-one-more-question-how-to/#findComment-417392 Share on other sites More sharing options...
freebsdntu Posted December 18, 2007 Share Posted December 18, 2007 This can be done easily in javascript,do a simple google search. Anyway,this is my code,just as a pointer html <select name="select" id = "link"> <option value="#">Sort By...</option> <option value="0">All Members</option> <option value="1">Username</option> <option value="2">Last Online</option> <option value="3">Online Only</option> <option value="4">Offline Only</option> </select> javascript function goto() { var link = document.getElementById("link").value; window.open(link); } Quote Link to comment https://forums.phpfreaks.com/topic/82137-solved-one-more-question-how-to/#findComment-417426 Share on other sites More sharing options...
pocobueno1388 Posted December 18, 2007 Share Posted December 18, 2007 <?php if (isset($_POST['sort'])){ $sort = $_POST['sort']; if ($sort == '1') $url = "www.something.php"; if ($sort == '2') $url = "www.somethingelse.php"; //keep going like this header("Location: $url"); } ?> <form id="sort" name="sort" method="post" action="action.php"> <label> <select name="select"> <option value="#">Sort By...</option> <option value="0">All Members</option> <option value="1">Username</option> <option value="2">Last Online</option> <option value="3">Online Only</option> <option value="4">Offline Only</option> </select> </label> </form> Quote Link to comment https://forums.phpfreaks.com/topic/82137-solved-one-more-question-how-to/#findComment-417429 Share on other sites More sharing options...
Lamez Posted December 18, 2007 Author Share Posted December 18, 2007 I found this! Thank you very much! <html> <head> <title>test</title> <script language="JavaScript"> <!-- function WinOpen() { var url=document.redirect.selection.value document.location.href=url } // --> </script> </head> <body> <form name="redirect"> <select name="selection"> <option value="#">Sort By...</option> <option value="viewmembers.php">All Members</option> <option value="viewmembers.php?sort=username">Username</option> <option value="viewmembers.php?sort=last">Last Online</option> <option value="viewmembers.php?sort=online">Online Only</option> <option value="viewmembers.php?sort=offline">Offline Only</option> </select> <input type=button value="Go!" onClick="WinOpen();"> </form> </body> </html> http://www.java2s.com/Code/JavaScript/Form-Control/DropdownRedirectSubmit.htm Quote Link to comment https://forums.phpfreaks.com/topic/82137-solved-one-more-question-how-to/#findComment-417430 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.