June 16, 2004

Checkboxes and missing values

Hi

Just read your article on php and forms. Thanks for putting such a resource on the web. Just one quick question though. I don't want to have a check box initially checked but when I leave it blank it doesn't show up in the results. I am trying to produce a csv so this leaves me with one less coloum.

Is there a way around this

Thanks
David


Hi, David!

The nature of checkboxes is that they only show up if they're selected. You can either use a radio button instead, or you can stay with the checkbox but also include an empty hidden field of the same name. That way there's always a "value" with that name, even if the checkbox doesn't come through. Be careful, though, you'll then have to deal with multiple values for a
single field.

I hope that helps!

---- Nick

Technorati tags: php | forms | reader questions | html | web development |

src="http://feeds.feedburner.com/~s/ChaosMagnet?i=http://www.chaosmagnet.com/blog/archives/000437.html" type="text/javascript" charset="utf-8">
Posted by roadnick at June 16, 2004 12:46 PM | TrackBack

Comments

Post a comment









Remember personal info?