Boxerman Posted February 8, 2010 Share Posted February 8, 2010 Hi guys, Im trying to get it so when a user selects something from the list it will update the URL and post the route.. heres my code <p>Preferred routes:</p> <form method="get" action="?"> <p>MTPP ARRIVALS</p> <p><select size="1" name=""> <option>MTCH-MTPP</option> <option>KJFK-MTPP</option> <option>KMIA-MTPP</option> <option>KFLL-MTPP</option> <option>TFFR-MTPP</option> <option>CYUL-MTPP</option> <option>TNCM-MTPP</option> <option>KBOS-MTPP</option> <option>CYYC-MTPP</option> <option>TNCC-MTPP</option> </select><input type="submit" value="Generate Route" name=""></p> <p><?php if (isset($_REQUEST['MTCH-MTPP'])){ echo "HCN G444 NOKEN PAP"; } ?> so it will be like index.php?MTCH-MTPP POSTS ROUTE HERE thanks Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 8, 2010 Share Posted February 8, 2010 so you mean you would just need <form method="get" action="index.php"> That would give you the url that you want Quote Link to comment Share on other sites More sharing options...
Boxerman Posted February 8, 2010 Author Share Posted February 8, 2010 Hi, theres a problem everytime i click it, it goes to this index.php?=MTCH-MTPP which is almost right.. i cant figure out where the = is coming from :S if that wasnt there it would work! Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 8, 2010 Share Posted February 8, 2010 ok the reason for this your unamed select should be <select name="route"> then you would get index.php?route=MTCH-MTPP which you should be able to work with Quote Link to comment Share on other sites More sharing options...
Boxerman Posted February 8, 2010 Author Share Posted February 8, 2010 ok i changed it and when i go the url is index.php?route=MTCH-MTPP but on my php the REQUEST is only if (isset($_REQUEST['MTCH-MTPP'])){ what else could be causing no show? Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 8, 2010 Share Posted February 8, 2010 if you absolutely need to just have index.php?MTCH-MTPP, then you would need to do this <script type="text/javascript"> function setRoute() { var elem = document.getElementById('route'); var route = elem.options[elem.selectedIndex].value; document.location.href = 'index.php?'+route; } </script> <select name="route" id="route"> .... </select> <input type="button" onclick="setRoute()" value="Generate Route" /> Quote Link to comment Share on other sites More sharing options...
alexjb Posted February 8, 2010 Share Posted February 8, 2010 If your url is index.php?route=MTCH-MTPP to retrieve the route, you would just use: $_REQUEST['route'] Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 8, 2010 Share Posted February 8, 2010 you have no $_REQUEST['MTCH-MTPP'] what you would have is $_REQUEST['route'] and that will be equal to the route selected so if($_REQUEST['route'] == 'MTCH-HTPP') { do something Quote Link to comment Share on other sites More sharing options...
Boxerman Posted February 8, 2010 Author Share Posted February 8, 2010 JL5501 THANKS YOU SIR!!! Quote Link to comment 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.