Jump to content

Working with Drop Down List


Timunit

Recommended Posts

Hi,

 

I am trying to query my database based on a drop down list and I am having trouble getting it to work. So I wrote some code to experiment with capturing the value of a drop down list but I am having trouble with that as well. I know I am missing something obvious but I am sort of a PHP newbie.

 

Here is the code:

 

echo "<form name='choosetrip' method='POST'><select name='trip'>";

echo "<option value='%'>Select a Trip</option>";

echo "<option value='2'>April 2008</option>";

echo "<option value='3'>April 2009</option>";

echo "</select>";

echo "</form><br>";

 

$trip = $_POST["trip"];

 

echo $trip;

 

if(isset($trip))

 

{

echo "YES";

 

} else {

 

echo "NO";

 

}

 

 

This is simply a drop down with three choices. I want the code to echo the value that is chosen and echo Yes or No whether the value has been set. But when I change the drop down nothing happens: no value shows and the answer remains No. For some reason the value of the drop is not being sent.

 

Any suggestions?

 

Thanks,

 

Tim

Link to comment
https://forums.phpfreaks.com/topic/129405-working-with-drop-down-list/
Share on other sites

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.