On Mon, 19 Feb 2001 15:43, toto wrote:
> the solution is javascript-based rather than php-based.
>
> Just put this code....and when you submit, the value you'll process
> stored in variable hidden_list_selected. each value selected are
> separated by comma delimiter.
>
> <html>
> <head>
> <script language="javascript">
> function insert(thisObject){
> thisForm = eval("document.frmInput");
> thisForm.hidden_list_selected.value = "";
>
> // flag to put comma as separate variable for each
>selected
> category flag_first = true;
>
>
>for(counter=0;counter<thisObject.options.length;counter++){
> if(thisObject.options[counter].selected){
> if(flag_first)
> flag_first = false;
> else
>
>thisForm.hidden_list_selected.value+= ",";
>
>thisForm.hidden_list_selected.value+=thisObject[counter].value;
> }
> }
> }
> </script>
> </head>
> <body>
>
> <form name="frmInput" method="post" action="testAction.php">
> <select name="sel_category" multiple size="4"
> onChange="javascript:insert(this);">
> <option value="Fruit">Fruit</option>
> <option value="vegetables">Vegetables</option>
> <option value="fish">Fish</option>
> </select>
> <input type="text" name="hidden_list_selected" value="">
> <input type="submit">
> </form>
> </body>
> </html>
>
>
> -----Original Message-----
> From: BeeBoo [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, February 17, 2001 11:42 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Multiple Selection.
>
>
> If i'm going to let users select multiple choices from a list in a
> form, let say the part in the form is like this:
>
> <select name="category" multiple size="4">
> <option value="Praise">Fruit</option>
> <option value="Worship">Vegetables</option>
> <option value="Fellowship">Fish</option>
> </select>
>
> what code should i put in the submit part of the php to collect the
> multiple inputs? I tried array, but it seems not working. Please help.
>
> Thanks.
>
I think you need to name the list as an array thus:
<select name="category[]" multiple size="4">
Then your receiving script can parse category as an array of the chosen
elements.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]