Re: dropdown Newbie question
| From: | Paul Nicholson | Date: | Thu, 05 Sep 2002 11:44:34 +0000 |
| Subject: | Re: dropdown Newbie question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-115295@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hey,
If your php version is > = 4.1.0 use:
$var_from_dropdown = $_GET['theme'];
else use:
$var_from_dropdown = $HTTP_GET_VARS['theme'];
You might want to change the method used to submit your form
from get to post, like:
// Start Dropdown
echo '<form name="theme" action="options.php" method="post"
target=right
class=menu>
Then you code should read: $var_from_dropdown = $_POST['theme']; or
$var_from_dropdown = $HTTP_POST_VARS['theme']; applying the rules from above.
Hope that helps!
~Pauly
On Thursday 05 September 2002 07:18 am, Scott Houseman wrote:
> Hi there.
>
> The value from that dropdown will be returned to you in the variable
>
> $_POST OR $_GET, depending on which method you used to submit the form.
>
> Assuming you use POST, you can access the selected value like this:
>
> $var_from_dropdown = $_POST['theme'];
>
> Regards
>
> -|Scott
>
> > -----Original Message-----
> > From: Mario Ohnewald [mailto:mario.ohnewald@gmx.de]
> > Sent: Thursday, September 05, 2002 1:11 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] dropdown Newbie question
> >
> >
> > Hello!
> > I am very new in php and i have a little dummy question ;D
> > I have a dropdown box with a entry in it called "Coctail Blue"
> > Now i want to put the selected string ("Coctail Blue" in this
> > case) in to a
> > variable when i press the button below.
> > options.php is the page it should go after.
> >
> > // ..SNIP ...
> >
> > // Start Dropdown
> > echo '
> > <form name="theme" action="options.php" target=right class=menu>
> > <select name="theme">';
> > for($i=0;$i<sizeof($theme_name);$i++)
> > {
> > echo "<option
> > value='".$i."'>".$theme_name[$i]."</option>\n";
> > }
> > //end dropdown
> >
> > // Button
> > echo '</select> <input type=submit name=get
> > value=select>';
> >
> > //doesnt work:
> > $var_from_dropdown = theme
> >
> > // ..SNIP ...
> >
> >
> > What did i do wrong?
> >
> > Thank you!
> > Mario
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
- --
~Paul Nicholson
Design Specialist @ WebPower Design
"The web....the way you want it!"
paul@webpowerdesign.net
"It said uses Windows 98 or better, so I loaded Linux!"
Registered Linux User #183202 using Register Linux System # 81891
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE9d0OmDyXNIUN3+UQRAmbzAJ9qUW6LYEndO81ybqFsMpeklHzs1wCfUGDK
Egom83QUipWIZ0ko2q1x5/s=
=OiSG
-----END PGP SIGNATURE-----