[FX.php List] Multi Selection Posting

Marisa Smith marisa at datasmithconsulting.net
Tue Apr 25 09:09:42 MDT 2006


Hi Gary -

I've never done this with multiple selections in a select box, but I  
imagine it works similarly to selecting multiple checkboxes:

In order to capture all of the checked items, you can name your input  
field as an array, like this:

<input type = "checkbox" name = "CopyTo[]" value = "value1">value1
<input type = "checkbox" name = "CopyTo[]" value = "value2">value2

If the user selects both boxes, the post is actually an ARRAY of  
values.  Then you can loop through the array and add it to the query.

foreach ($_POST as $key => $value)
	{
		if(is_array($value) == "1")//if the post variable contains an array  
of values from a checkbox
		{
		$v = '';
		$val = '';
		foreach ($value as $k => $v)  //loop through the array, and  
separate the values with a return.
			{
			$val .= $v."\r";
			}
		$val = substr_replace($val,"",strrpos($val,"\r"));//chop off the  
last carriage return
		$value = $val;
		}
		
		$query->AddDBParam($key,$value);
			
	}


Let us know if it works the same for selecting multiple items in a  
select box!
Marisa

---------------------------------------------------------------------
Marisa Smith, President
DataSmith Consulting, LLC
9206 Huron River Drive
Dexter, MI 48130
Phone & Fax: (734) 426-8077
http://www.datasmithconsulting.net
Filemaker Solutions Alliance Associate Member

On Apr 25, 2006, at 10:58 AM, gerry.charest at agfa.com wrote:

> I have a form that allows for the selection of multiple items from  
> a list. Upon reviewing the entries in the database I see that I am  
> only getting the first item selected. Further reviewing the POST  
> value for the field in question I see that only one value was  
> received. Is there something missing, do I need to do something  
> special to send and post multiple selection?
>
> Here is the form field for the value list posting.
>
> <select name="CopyTo" size="3" multiple>
> <option value=""></option>
> <?php
> foreach ($searchUserResult['data'] as $key => $searchUserData){
> echo '"<option value="'.$searchUserData['NameFullLastFirst'] 
> [0].'">'.$searchUserData['NameFullLastFirst'][0].'</option>"';
> }
> ?>
> </select>
>
>
> Best Regards
>
> Gerry Charest
> Agfa Corporation
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20060425/a56a3293/attachment-0001.html


More information about the FX.php_List mailing list