943,975 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 25052
  • PHP RSS
Jan 17th, 2007
0

Get value from checkbox

Expand Post »
Hi all,

I have used the checkboxes in my page as given below
PHP Syntax (Toggle Plain Text)
  1. <input type="checkbox" name="chkboxarray" value=1>
  2. <input type="checkbox" name="chkboxarray" value=2>
  3. <input type="checkbox" name="chkboxarray" value=3>

If all the checkboxes are selected then how can we get the values of individual checkbox in php during a form submission. Anyone have idea for this?
Last edited by stymiee; Jan 17th, 2007 at 10:42 am. Reason: fixed code tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
mahe4us is offline Offline
54 posts
since Sep 2006
Jan 17th, 2007
0

Re: Get value from checkbox

<input type="checkbox" name="chkboxarray[]" value=1>
<input type="checkbox" name="chkboxarray[]" value=2>
<input type="checkbox" name="chkboxarray[]" value=3>

To access them as a group:
php Syntax (Toggle Plain Text)
  1. foreach ($_REQUEST['chkboxarray'] as $checkbox)
  2. {
  3. echo $checkbox;
  4. }
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Jan 19th, 2007
0

Re: Get value from checkbox

Hi Stymiee,

Thanks for your kind reply. I have mentioned checkbox name as an array like chkboxarray[] and then get the individual value from the checkbox.

thanku..
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
mahe4us is offline Offline
54 posts
since Sep 2006
Jan 19th, 2007
0

Re: Get value from checkbox

Since they all share the same name you can't get them individually. You'll need to look for the value of each and base your actions on that. Your only alternative is to give each one a unique name in your HTML.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP+Mysql+mediumblob
Next Thread in PHP Forum Timeline: Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC