Page 1 of 1
drop down form
Posted: Wed May 04, 2011 4:05 pm
by dbarron87
hello, hopefully this is in the correct section.
i am wondering how i would retrieve the following forms chosen option
Code: Select all
<FORM METHOD=GET ACTION=ship_detail.php
<select name='myCarrier'>
<option value='dhl'>DHL</option>
<option value='ups'>UPS</option>
<option value='fedex'>Fedex</option>
<option value='mompap'>Mom And Pap</option>
<option value='somepost'>Some Post</option>
</select>
i would luke to receive the chosen option on a page known as detail.php
thanks for your help in advance.
Re: drop down form
Posted: Thu May 05, 2011 1:57 am
by eivind
First of all you miss a '>' on the end of your form tag.
You can retrieve it with $_GET['myCarrier'] on whichever page you chose to set action= to.
Re: drop down form
Posted: Thu May 05, 2011 4:22 pm
by dbarron87
kunalk wrote:Are you trying to submit the data to detail.php(as per your post) or ship_detail.php (as per your code)?
yes i think that is what i am trying to do, being to detail.php
Re: drop down form
Posted: Thu May 05, 2011 4:35 pm
by dbarron87
eivind wrote:First of all you miss a '>' on the end of your form tag.
You can retrieve it with $_GET['myCarrier'] on whichever page you chose to set action= to.
This is going to sound silly but i still do not understand. i have read so many types of forms the past 3 weeks i have a complete mental block.
would it just be something like
<? $_GET['myCarrier'] ?>
and how would the script no to put the chosen option in to text for example?
your help is appreciated as it's helping me learn.
many thnaks
Re: drop down form
Posted: Mon May 09, 2011 6:03 am
by eivind
try <? echo $_GET['myCarrier'] ?> and see what comes out

Re: drop down form
Posted: Mon May 16, 2011 6:59 am
by Gopesh
Hi,this is complete code that gets the values and prints to another page..
Code: Select all
<FORM method="get" action="detail.php">
<select name='myCarrier'>
<option value='dhl'>DHL</option>
<option value='ups'>UPS</option>
<option value='fedex'>Fedex</option>
<option value='mompap'>Mom And Pap</option>
<option value='somepost'>Some Post</option>
</select>
<input type="submit" value="submit" />
</FORM>
The code for detail.php is as follows
Code: Select all
<?php
$name=$_GET['myCarrier'];
echo $name;
?>
Try to use $_POST for passing values.
Hope that it works for u...