How do I check if a checkbox is selected, ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

How do I check if a checkbox is selected, ?

Post by Mythic Fr0st »

I have a simple terms & conditions checkbox, I need to know how I can tell if its selected

E.G if (t&c == checked)
{
actions here
}
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Checkboes represent themselves as either empty or 'on'.
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

Post by Mythic Fr0st »

k, thanks


if (name == on)
i assume thats it
TheProgrammer
Forum Newbie
Posts: 22
Joined: Mon Nov 27, 2006 12:25 am

Post by TheProgrammer »

actually you should check if is set. something like this:

Code: Select all

if( isset(name) && name==true){...}
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

Post by Mythic Fr0st »

I have, that was just me typing a shorter version

real one has the isset() thing with it
Post Reply