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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.