Jump to content

[SOLVED] Problem using <select>


KevinM1

Recommended Posts

I have a form which uses selection options as values to pass to the script which handles the data.  Unfortunately, it looks like that second script isn't recognizing that an option is highlighted/selected in the first script at all.  It's a setup that works like this:

 

Form script:

<?php

echo "<form method='post' action='handler.php'>\n";
echo "<select>\n";
echo "<option name='all' value='*'>All</option>\n";
echo "<option name='1' value='1'>1</option>\n";
.
.
.
echo "<option name='nth' value='nth'>nth</option></select></form>";

?>

 

handler.php:

<?php

if(isset($_POST['all'])){
   //process stuff
}

?>

 

Obviously, this example is a bit simpler than what I'm doing, but it does accurately describe what I'm trying to attempt.  Unfortunately, like I said above, it looks like my handler script isn't recognizing that whatever option I select is set (in other words, it looks like isset is failing).  Any ideas?  I will show the real code if necessary.

Link to comment
Share on other sites

you want the <select> as variable.. therefor you need to give it the name

 

write: <select name="all">...blalblabla

 

the <option> tags don't have names.. just values. (the value you choose will then be in the $_POST['all'] variable..

 

Ah, thanks! :)

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.