Forum Moderators: coopster

Message Too Old, No Replies

How To Print All Selected Items From Dropdown?

         

phpNewb

4:46 pm on Aug 24, 2007 (gmt 0)

10+ Year Member



Hello List!

I could really use some help here...I've almost got this working, but need some answers...

I have a program that allows users to select a 'New Graduate' membership, and for each one selected, they get a free tshirt. I've got that working using a 'is_new_grad' function that I created. So, if they select 2, they see 2 dropdowns to select the sizes of them. It then sends an email w/ the membership info and the shirt sizes selected.

However, when the email is being sent, it's only returning the size of the LAST item selected in from the drop-downs. Example: if I sign up for four of these memberships and select four different tshirt sizes (1 Medium, 1 Lg, 1 XL, and 1 XXL), the info in the email is all XXL:

New Graduate T-Shirt Size (included): XXL
New Graduate T-Shirt Size (included): XXL
New Graduate T-Shirt Size (included): XXL
New Graduate T-Shirt Size (included): XXL

Here's my code for showing the drop-down boxes:


if( is_new_grad() ) //If joined as a 'New Graduate', ask for the T-Shirt size - 1 for each 'New Graduate' membership
{
while(list($product_id, $quantity) = each($_SESSION["cart_items"]))
{
for( $count = 1; $count <= $quantity; $count++)
{

$shirt_sizes = array("M" => "Medium (M)", "L" => "Large (L)", "XL" => "Extra Large (XL)", "XXL" => "Extra Extra Large (XXL)" );

<TR BGCOLOR=#CCCCCC>
<TD CLASS="bodytext"><FONT COLOR=#961039>Select T-Shirt Size (included):</font></TD>
<TD>&nbsp;</TD>
<TD COLSPAN=5 ALIGN=RIGHT>
<SELECT NAME="tsize">
<OPTION VALUE="">--Select--</OPTION>

foreach( $shirt_sizes as $key => $value )
{
echo "<OPTION VALUE='".$key."' ";
if( $tsize == $key )
{
echo " SELECTED ";
}
echo " >".$value."</OPTION>\n";
}
</SELECT>
</TD>
</TR>
} //end of for loop
}//end of while
}//END if( is_new_grad() )

And here's the code for sending the email:


if( is_new_grad() ) //If joined as a 'New Graduate', ask for the T-Shirt size
{
while(list($product_id, $quantity) = each($_SESSION["cart_items"]))
{
for( $count = 1; $count <= $quantity; $count++)
{
if( $_POST["tsize"] )
{
echo "\tNew Graduate T-Shirt Size (included): ".$_POST["tsize"]."\n";
}
}
}
}

Please, any solutions and ideas for solving this would be greatly appreciated!

Thank for your time and help!
-j.g.

d40sithui

5:26 pm on Aug 24, 2007 (gmt 0)

10+ Year Member



i think the problem is your <select> statement. you need different names for each <select>. so you should have something like

<select name="tsize1">
...
<select name="tsize2">
...