Re: How to use SELECT with multiple options enabled in forms....

From: Date: Fri, 21 Nov 2003 02:39:59 +0000
Subject: Re: How to use SELECT with multiple options enabled in forms....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-170515@lists.php.net to get a copy of this message
Robert Restad wrote:
Now, use SELECT is simple enough. The Select Name gives a value, the one you selected of course... However, I yet have to find a way to actually determine how I could fetch i.e. the results from a SELECT multiple-choice menu. What if I want the website visitor to choose from multiple values, and read them in a PHP script after the form is submitted? Suggestions or ideas of how to solve this? I figured this is probably a very easy task, but I've done a couple attempts, and yet unsuccessful... I can make and read the values of multiple checkboxes, but I cant figure out how to do this with a select ... Best regards, Robert.
This question was just asked a few hours ago, on this very list (not to mention the few times a week). Anyway, since the list archives /must/ be broken.... <select name="whatever[]" multiple> <option value="thisValue" />Choose ..... <option value="thatValue" />Choice </select> Now, putting the square brackets after the name of your form element, will pass the results as an array, which will now be available to your php script as.... $_POST['whatever'] It will be an array, even if only one option is selected, so please treat as such. -- By-Tor.com It's all about the Rush http://www.by-tor.com

« previous php.general (#170515) next »