Current location: Hot Scripts Forums » Programming Languages » PHP » how to read un-checked checkbox values in PHP?


how to read un-checked checkbox values in PHP?

Reply
  #1 (permalink)  
Old 07-19-10, 03:35 PM
SoftDux SoftDux is offline
Newbie Coder
 
Join Date: Mar 2008
Location: Johannesburg,South Africa
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
how to read un-checked checkbox values in PHP?

Hi everyone,

I need to capture dynamic form data in a PHP script, and would like to know how to capture un-checked checkboxes as well? Basically I have a list of usernames, each with a checkbox next to it. An admin person then needs to tick the checkboc next to a name, when the user has met certain criteria (say for example, pupils attending class).

When the form is submitted, a piece of code will send an email to a designated recipient (for example The Dean) with a list of attendees. But at the same time I also want to indicate which names weren't selected.

i.e.

"The following students attended the session:
John
Bob
Ann
Alex
Peter

The following students didn't attend:
Frank
Paul
Joe"

Does this make sense?

The question is, how do I see which are unchecked, but from a list dynamically generated? i.e. when the teacher choose the list of candidates, she has a list of criteria to choose from, which then generates the list. So the list could have 2 names or 20 names.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-20-10, 09:10 AM
sourcez sourcez is offline
New Member
 
Join Date: Feb 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
You have the variables passed to the form as true/false for the names so why not just use some conditional statements?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-20-10, 09:15 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Does the list of users come form a database?

If so, you cold pull this list again on the second page, and match it against the submitted values.

Or you could use radio buttons instead of checkboxes.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-20-10, 09:20 AM
SoftDux SoftDux is offline
Newbie Coder
 
Join Date: Mar 2008
Location: Johannesburg,South Africa
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by sourcez View Post
You have the variables passed to the form as true/false for the names so why not just use some conditional statements?
Cause the form values are all dynamic, so I can't do a true false, since I don't know at coding time what values the form has.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-23-10, 03:17 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Quote:
Originally Posted by SoftDux View Post
Cause the form values are all dynamic, so I can't do a true false, since I don't know at coding time what values the form has.
The database must have a column for each checkbox that can be used.
A query to the database should be able to tell you which checkboxes were checked and which were not.
What I mean is, if you want to query the database to see how many people checked a certain box, then there should be a column in the database for that checkbox and if they checked it, then there will be a value in it. If they didn't check a certain box, then there won't be a value in it.

It shouldn't matter how many check boxes are dynamically created in any given form.
Because there should be a column for each possible checkbox in the database.
And those columns should have a value if the checkbox was checked and no value if it wasn't.
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP to read txt file. sander100 Script Requests 0 07-09-10 08:53 AM
Php to read xml kavitha123 PHP 2 03-21-10 11:32 PM
Read XML-RSS file from PHP? Anisking PHP 1 11-20-06 09:02 AM
Nothing happen if checkbox checked zoliky PHP 1 09-21-06 03:13 AM
How to get values from checked checkboxes? Godwin PHP 3 09-19-06 01:17 AM


All times are GMT -5. The time now is 12:36 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.