Re: [PHP] dynamic checkboxes?
On Mon, 6 Aug 2001 08:57:08 -0500, garman ([EMAIL PROTECTED]) wrote: >I have a form that generates a list of "categories" dynamically. >That is, for >each category in a database, the form has a corresponding checkbox. >The >checkboxes are given serialized names, such as "chkbx1", "chkbx2", >etc. > >I'm having trouble figuring out how to process these in the php >script that >handles this form. In other words, how do I figure out which >categories were >selected when I don't know in advance how many categories there are? > How can >I check if the form variables "chkbx1", "chkbx2", etc have been set? name them chkbx[1], chkbx[2]... then on the next page go: foreach($chkbx as $key=>$value){ echo "chkbx[$key] is set.\n"; } >Thanks, >Matt > > >-- >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: php-list- >[EMAIL PROTECTED] -- 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]
[PHP] dynamic checkboxes?
I have a form that generates a list of "categories" dynamically. That is, for each category in a database, the form has a corresponding checkbox. The checkboxes are given serialized names, such as "chkbx1", "chkbx2", etc. I'm having trouble figuring out how to process these in the php script that handles this form. In other words, how do I figure out which categories were selected when I don't know in advance how many categories there are? How can I check if the form variables "chkbx1", "chkbx2", etc have been set? Thanks, Matt -- 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]
Re: [PHP] dynamic checkboxes
What you need to do is to have a function in the form processing page that iterates through $HTTP_POST_VARS and saves the name and value of each item in the form. You will want to exclude your submit button and if there are other form items you don't want to save, you might want to name them with a unique name (such as prepending "nosave") so you can exclude them as well. The function I wrote to do this is as follows: function SetAllAnswers() { global $HTTP_POST_VARS; foreach($HTTP_POST_VARS as $qID=>$value) { if ($qID != 'submit' && !stristr($qID,'nosave')) $this->SetAnswer($qID, $value); } } ""Nando2"" <[EMAIL PROTECTED]> wrote in message 021101c0c1f1$fb3e0a00$0ab4c5c8@Nando4">news:021101c0c1f1$fb3e0a00$0ab4c5c8@Nando4... Hello All, I'm trying to build a way to transfer my orders to a HTML page instead of using GUI that I've designed. In order to do that I need to display all the orders of the day and have checkboxes on each so that the user can select only the orders that we will process. The number of checkboxes on this form will depend on the number of orders of that day. So the form and the number of its variables will be dynamic as well. Each checkbox has to have the name property that can be matched to the customercode+ordernumber. After the form is submited I need to scan all the variables that were checked so that it can be included on the next query. Has anyone tried that or did that before? Is there any URL or PHP code that can be used to learn that? Thank you very much, Carlos Fernando. -- 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]
[PHP] dynamic checkboxes
Hello All, I'm trying to build a way to transfer my orders to a HTML page instead of using GUI that I've designed. In order to do that I need to display all the orders of the day and have checkboxes on each so that the user can select only the orders that we will process. The number of checkboxes on this form will depend on the number of orders of that day. So the form and the number of its variables will be dynamic as well. Each checkbox has to have the name property that can be matched to the customercode+ordernumber. After the form is submited I need to scan all the variables that were checked so that it can be included on the next query. Has anyone tried that or did that before? Is there any URL or PHP code that can be used to learn that? Thank you very much, Carlos Fernando.