Value returned from checkbox?

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
Dave2000
Forum Contributor
Posts: 126
Joined: Wed Jun 21, 2006 1:48 pm

Value returned from checkbox?

Post by Dave2000 »

This seems like a simple question, but... :?

What value is returned from a checkbox in a form?

For example, if the checkbox was named "word" ie. <input type="checkbox" name="word">...

I looked at Echo $_POST['word'], the value shown was "on", yet an, if ( $_POST['word'] == "on" ) or ( $_POST['word'] == on ) wouldn't return true. I've tried many other things too but none seem to work :?

/me scratches head... Anyone know? :oops:
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

correct me if I'm wrong, but won't it return the value you set?

<input ... value="foobar">
Dave2000
Forum Contributor
Posts: 126
Joined: Wed Jun 21, 2006 1:48 pm

Post by Dave2000 »

oh yeah LOL :oops:

I was reading a website, and i cant have been paying attention to it too closely as i just beleived what it said... "Notice that there is no value attribute for checkboxes, as they will either be checked or left blank." Oh wells. Thank you :)
Post Reply