Jump to content

problem with getting data from form


Boxerman

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/191343-problem-with-getting-data-from-form/
Share on other sites

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" />

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.