View Full Version : Mulitple items from drop down list
UNHAPPY@HR
06-16-2004, 08:06 PM
I'm using a drop down list for users to select colors. they can select multiple colors. However, only one color shows up in the email.
I can create an array by setting the item on the page to
<select name="color1[]" size="3" multiple="MULTIPLE">
adding the [] in there creates the array, but how do i call the array back up correctly in the server side php?
UNHAPPY@HR
06-24-2004, 04:13 PM
anyone??? Anyone???
Silmaril8n
06-29-2004, 08:29 PM
I don't quite understand what is it that you are doing but I've never seen "Select" box HTML written that way.
UNHAPPY@HR
06-29-2004, 09:30 PM
well, whenever you created a drop down list, that's how it's done. i figured it out. created an array..blah blah blah, i have a fabulous system now.
Silmaril8n
06-30-2004, 03:55 PM
Well if you were doing it to standards this is what a select form looks like:
<select title="Please choose your favorite town" name="ddlTown" id="ddlTown">
<option value="">Please Select ... </option>
<option value="Swindon">Swindon</option>
<option value="London">London</option>
<option value="Burkino Faso">Burkino Faso</option>
</select>
But if you got everything working the way you need then righton
UNHAPPY@HR
06-30-2004, 04:06 PM
welli it wasn't the form that was the problem, it was the PHP on the backside that was the problem. I had to make my own formmailer php from scratch pretty much.
<select name="color2[]" size="3" multiple="MULTIPLE">
<option selected="selected">pearl pink</option>
<option>red</option>
<option>blue</option>
<option>green</option>
<option>purple</option>
That's the form part
then this is how I got it to break down in PHP to actually show the multiple results instead of just the last one picked.
foreach($color2 as $stuff => $value)
{ $found=0; for($i=0;$i<count($def);$i++)
{
if($stuff==$def[$i])
{ $found=1;
}
}
if(!$found==1)
{ $message.=$stuff." : ".$value."\n";
}
}
all in all...I had to read up on PHP syntax to figure it out. I knew that it had to be an array, and handling arrays is a snap, but you gotta know the syntax.
Silmaril8n
06-30-2004, 04:34 PM
Nice - I knew that I didn't understand what was up. I get it now... nice solution too BTW
UNHAPPY@HR
06-30-2004, 09:55 PM
yeah, and only took me 13 hours straight to finally figure it out. also that usage of array will work if you use the HTTP_POST command, but instead of one item, it arrays out every part of your form for you. so instead of color2 you use $HTTP_POST_VARS. which makes a form awesomely handy, because you don't have to identify every part of the form, it automatically gets it for you. I have slowly fallen in love with PHP.
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.