RE: [PHP] Not losing variables in forms w/ checkboxes

From: Date: Fri, 18 May 2001 19:34:25 +0000
Subject: RE: [PHP] Not losing variables in forms w/ checkboxes
Groups: php.general 
Request: Send a blank email to php-general+get-53473@lists.php.net to get a copy of this message
Just append a pair of brackets to the NAME in the FORM: suspendingAgent[]. This will create an array for the boxes that get checked. To get the array to a comma separated list on the processing page, try: $string = implode (",", $suspendingAgent); Kirk > -----Original Message----- > From: Andrew V. Romero [mailto:Rom98ero@pharmacy.arizona.edu] > Sent: Friday, May 18, 2001 1:15 PM > To: php-general@lists.php.net > Subject: [PHP] Not losing variables in forms w/ checkboxes > > > I am working on creating some html forms (that are parsed by PHP) and > need to use checkboxes, and was wondering how would you go about > creating the checkboxes so that once the user hits the submit button, > all of the checkbox variables are included? Right now I have: > echo "<input TYPE =\"checkbox\"NAME=\"suspendingAgent\" > VALUE=\"$availSuspendingAgentNames[$i]\" > > $availSuspendingAgentNames[$i]"; > In my understanding with how it is now, if the user chooses more than > one suspending agent, only one suspending agent will be sent > to the php > file once the submit button is hit. The problem is that the > program is > pulling the names of an unknown number of suspendingAgents from a file > so I can not just pick say two different names for the check > boxes. The > only solution that I have thought of is to create a NAME > array then each > checkbox would have its own name such as suspendingAgent[0], but this > seems rather cumbersome seeing as I would then have to write more code > to figure out which check box names were checked. So I was > wondering if > there was an easier way to go about this? It would be excellent if > there was someway to have the script combine all the values of the > checked check boxes into one value seperated by commas and > have it still > with the name of suspendingAgent. > Thanks for any ideas, > Andrew V. Romero > To reply personally, remove all numbers from my address. > > > -- > 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 (#53473) next »