Page 1 of 1
Quick question on checkboxes
Posted: Mon Jul 16, 2007 11:45 am
by McManCSU
Is there a need to use the 'value' attribute for checkboxes? For example, if I have something like this:
Code: Select all
<input name="checkbox" type="checkbox" checked="checked">
Is there a need for the 'value' attribute, since the POST array will have the 'name' if it was checked on page submission (otherwise it wouldn't be there)?
Posted: Mon Jul 16, 2007 11:53 am
by dxm
checked is a HTML parameter, it allows you to decide whether the checkbox should be checked by default. It has nothing to do with passing the state to PHP.
Posted: Mon Jul 16, 2007 1:19 pm
by RobertGonzalez
Do checkboxes even have a value attribute? PHP sees them as either null or 'on' when passed in a form.
Posted: Mon Jul 16, 2007 1:33 pm
by Burrito
Everah wrote:Do checkboxes even have a value attribute? PHP sees them as either null or 'on' when passed in a form.
yes and the value attribute is very helpful when dealing with checkbox arrays...
Posted: Mon Jul 16, 2007 2:22 pm
by RobertGonzalez
You know what, I do remember that. I haven;t used checkboxes in probably two years, but I remember passing values in them. Sorry about that.