Page 1 of 1

Collect Multiple selections from Drop down then post

Posted: Mon Nov 20, 2006 4:12 am
by JimiH
Hello

I have a dropdown box populated with a list of names

Code: Select all

<td>Project Member Select</td>
                <td align="left">

<?
	echo"<select name=\"Project Member Select\">"; 
	while($row=mysql_fetch_assoc($my_query3)) 
	{ 
	echo  "<option value=\"".$row['Name']."\">".$row['Name']."</option>"; 
	} 
?>
</td>
<td><input type="submit" name="Submit" value="Add Member"></td> //<<<<THIS LINE IS A GUESS,THINK I NEED IT TO POST TO ITSELF

</tr>
<tr>
I would like the user to select a value then "Add Member", select another value then "Add Member" etc etc, until the user has selected all the names he wishes. The id ="Project_Members" would contain all the values selected seperated by a ";" Example "Bill;Ben" etc

Thanks

Geoff

Posted: Mon Nov 20, 2006 8:11 am
by JimiH
Ok

Managed to sort it using a multiple selection box.

See below

Input form section

Code: Select all

<?
	echo"<select name=\"Project_Members_Select[]\" multiple=\"multiple\">" ; 
	while($row=mysql_fetch_assoc($my_query3)) 
	{ 
	echo  "<option value=\"".$row['Name']."\">".$row['Name']."</option>"; 
	} 

?>
Form submit section

Code: Select all

$Project_Members=$_POST["Project_Members_Select"];
for ( $ii = 0 ; $ii < count($Project_Members) ; $ii++ )
{
$choose_branch = $choose_branch . " " . $Project_Members[$ii] ;
}

//$result = "You selected : " . $choose_branch ;
                                                 
$Project_Members = $choose_branch;


$sql="insert into $branch(VSI_NUMBER,Salesman,ENGINEER,CUSTOMER,SALESGROUP,
SICCODE,N_E,YEARQTY,CHCKLRATIO,VALUEExworks,DATEIN,COMMENTS,ACTIONDATE,
Project_Members,Gate,Job_No,Cata_Number) 

values('$VSI_NUMBER','$Salesman','$ENGINEER','$CUSTOMER','$SALESGROUP','$SICCODE'
,'$N_E','$YEARQTY','$CHCKLRATIO','$VALUEExworks','$DATEIN','$COMMENTS','$ACTIONDATE',
'$Project_Members','$Gate','$Job_No','$Cata_Number')";
Hope this helps someone else!

Geoff