Re: [PHP] how can php get the values of a group of checkbox
On Friday 22 November 2002 08:35, Xin Qi wrote: > RE: [PHP] how can php get the values of a group of checkboxbut the question > is how to determine the times of loop? the upper bound is hard to find. and > the loop does cost time though it is not so much. If you have made the checkbox values into an array either explicitly using $checkbox[1], or implicitly using $checkbox[], then you just do: foreach ($checkbox as $key => $value) { echo "Value of checkbox $key is $value Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* A fool-proof method for sculpting an elephant: first, get a huge block of marble; then you chip away everything that doesn't look like an elephant. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how can php get the values of a group of checkbox
RE: [PHP] how can php get the values of a group of checkboxbut the question is how to determine the times of loop? the upper bound is hard to find. and the loop does cost time though it is not so much. - Original Message - From: Van Andel, Robert To: Xin Qi ; [EMAIL PROTECTED] Sent: Thursday, November 21, 2002 7:18 PM Subject: RE: [PHP] how can php get the values of a group of checkbox Use an array (checkbox[1], checkbox[2]). Then use a loop to pull get the data after posting. If you expect only one choice, use a radio button. Robbert van Andel -Original Message- From: Xin Qi [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 21, 2002 1:54 PM To: Van Andel, Robert; [EMAIL PROTECTED] Subject: Re: [PHP] how can php get the values of a group of checkbox RE: [PHP] how can php get the values of a group of checkboxthank you, but what if all the checkboxes are generated dynamicly? I mean, I do not know how many checkboxes where will be until the php script generate the html page completely. if i have them unique names, it is kind of boring when php loads $_GET[] because it will be $_GET[$one_variable]. For a group checkboxes with the same name, there will be no such problem. - Original Message - From: Van Andel, Robert To: Xin Qi ; [EMAIL PROTECTED] Sent: Thursday, November 21, 2002 4:26 PM Subject: RE: [PHP] how can php get the values of a group of checkbox Check boxes should not be given the same name. Radio buttons should to denote a grouping. In other words, if you want to have a bunch of radio buttons indicating a choice between items (say bananas, oranges, and apples), you would name them the same thing and give them each a different value. Checkboxes need to be given unique names to identify them. Using the example above, you would have three check boxes one called bananas, one called oranges and one called apples. They are given the value of true when they are submitted. You could probably hard code the value as well, but I rarely do so. Robbert van Andel -Original Message- From: Xin Qi [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 21, 2002 11:14 AM To: [EMAIL PROTECTED] Subject: [PHP] how can php get the values of a group of checkbox hi there, if i have a group of checkboxes, and they have the SAME name, when they are submited into a php script, how can this php file get the value of each checkbox? since they have the same name, $_GET["checkbox_name"] only returns the last one. thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php "The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers." "The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers."
RE: [PHP] how can php get the values of a group of checkbox
Use an array (checkbox[1], checkbox[2]). Then use a loop to pull get the data after posting. If you expect only one choice, use a radio button. Robbert van Andel -Original Message- From: Xin Qi [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 21, 2002 1:54 PM To: Van Andel, Robert; [EMAIL PROTECTED] Subject: Re: [PHP] how can php get the values of a group of checkbox RE: [PHP] how can php get the values of a group of checkboxthank you, but what if all the checkboxes are generated dynamicly? I mean, I do not know how many checkboxes where will be until the php script generate the html page completely. if i have them unique names, it is kind of boring when php loads $_GET[] because it will be $_GET[$one_variable]. For a group checkboxes with the same name, there will be no such problem. - Original Message - From: Van Andel, Robert To: Xin Qi ; [EMAIL PROTECTED] Sent: Thursday, November 21, 2002 4:26 PM Subject: RE: [PHP] how can php get the values of a group of checkbox Check boxes should not be given the same name. Radio buttons should to denote a grouping. In other words, if you want to have a bunch of radio buttons indicating a choice between items (say bananas, oranges, and apples), you would name them the same thing and give them each a different value. Checkboxes need to be given unique names to identify them. Using the example above, you would have three check boxes one called bananas, one called oranges and one called apples. They are given the value of true when they are submitted. You could probably hard code the value as well, but I rarely do so. Robbert van Andel -Original Message- From: Xin Qi [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 21, 2002 11:14 AM To: [EMAIL PROTECTED] Subject: [PHP] how can php get the values of a group of checkbox hi there, if i have a group of checkboxes, and they have the SAME name, when they are submited into a php script, how can this php file get the value of each checkbox? since they have the same name, $_GET["checkbox_name"] only returns the last one. thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php "The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers." "The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers."
Re: [PHP] how can php get the values of a group of checkbox
RE: [PHP] how can php get the values of a group of checkboxthank you, but what if all the checkboxes are generated dynamicly? I mean, I do not know how many checkboxes where will be until the php script generate the html page completely. if i have them unique names, it is kind of boring when php loads $_GET[] because it will be $_GET[$one_variable]. For a group checkboxes with the same name, there will be no such problem. - Original Message - From: Van Andel, Robert To: Xin Qi ; [EMAIL PROTECTED] Sent: Thursday, November 21, 2002 4:26 PM Subject: RE: [PHP] how can php get the values of a group of checkbox Check boxes should not be given the same name. Radio buttons should to denote a grouping. In other words, if you want to have a bunch of radio buttons indicating a choice between items (say bananas, oranges, and apples), you would name them the same thing and give them each a different value. Checkboxes need to be given unique names to identify them. Using the example above, you would have three check boxes one called bananas, one called oranges and one called apples. They are given the value of true when they are submitted. You could probably hard code the value as well, but I rarely do so. Robbert van Andel -Original Message- From: Xin Qi [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 21, 2002 11:14 AM To: [EMAIL PROTECTED] Subject: [PHP] how can php get the values of a group of checkbox hi there, if i have a group of checkboxes, and they have the SAME name, when they are submited into a php script, how can this php file get the value of each checkbox? since they have the same name, $_GET["checkbox_name"] only returns the last one. thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php "The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers."
RE: [PHP] how can php get the values of a group of checkbox
Check boxes should not be given the same name. Radio buttons should to denote a grouping. In other words, if you want to have a bunch of radio buttons indicating a choice between items (say bananas, oranges, and apples), you would name them the same thing and give them each a different value. Checkboxes need to be given unique names to identify them. Using the example above, you would have three check boxes one called bananas, one called oranges and one called apples. They are given the value of true when they are submitted. You could probably hard code the value as well, but I rarely do so. Robbert van Andel -Original Message- From: Xin Qi [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 21, 2002 11:14 AM To: [EMAIL PROTECTED] Subject: [PHP] how can php get the values of a group of checkbox hi there, if i have a group of checkboxes, and they have the SAME name, when they are submited into a php script, how can this php file get the value of each checkbox? since they have the same name, $_GET["checkbox_name"] only returns the last one. thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php "The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers."
Re: [PHP] how can php get the values of a group of checkbox
user name=cb[] and PHP will automatically make the array. then call it with $_GET["cb"][#] Adam On Thu, 21 Nov 2002, Xin Qi wrote: > hi there, > > if i have a group of checkboxes, and they have the SAME name, when they are > submited into a php script, how can this php file get the value of each > checkbox? > > since they have the same name, $_GET["checkbox_name"] only returns the last > one. > > thanks > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how can php get the values of a group of checkbox
At 20:14 21.11.2002, Xin Qi said: [snip] >if i have a group of checkboxes, and they have the SAME name, when they are >submited into a php script, how can this php file get the value of each >checkbox? > >since they have the same name, $_GET["checkbox_name"] only returns the last >one. [snip] If you name your checkboxes "checkbox_name[]" (note the brackets behind the name) PHP will recognize the parameters being an array so you will have all (checked) values at your disposal. For checkboxes this means that _unchecked_ options are NOT transmitted. Might be a caveat depending on your implementation. -- >O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php