Get value from checkbox

Thread Solved

Join Date: Sep 2006
Posts: 54
Reputation: mahe4us is an unknown quantity at this point 
Solved Threads: 0
mahe4us's Avatar
mahe4us mahe4us is offline Offline
Junior Poster in Training

Get value from checkbox

 
0
  #1
Jan 17th, 2007
Hi all,

I have used the checkboxes in my page as given below
  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
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Get value from checkbox

 
0
  #2
Jan 17th, 2007
<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:
  1. foreach ($_REQUEST['chkboxarray'] as $checkbox)
  2. {
  3. echo $checkbox;
  4. }
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 54
Reputation: mahe4us is an unknown quantity at this point 
Solved Threads: 0
mahe4us's Avatar
mahe4us mahe4us is offline Offline
Junior Poster in Training

Re: Get value from checkbox

 
0
  #3
Jan 19th, 2007
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..
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Get value from checkbox

 
0
  #4
Jan 19th, 2007
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.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC