RE: [PHP] Multiple Selection.

From: Date: Mon, 19 Feb 2001 05:13:33 +0000
Subject: RE: [PHP] Multiple Selection.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-40507@lists.php.net to get a copy of this message
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:im_lymab@hotmail.com] Sent: Saturday, February 17, 2001 11:42 PM To: php-general@lists.php.net 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#40507) next »