Checkbox Values

2 posts by 2 authors in: Forums > CMS Builder
Last Post: November 5, 2014   (RSS)

By zaba - October 30, 2014

A Little confused, In CMS the default Values for a checkbox are

Checked 'Yes'

Unchecked 'No'

So submitting a Value of 'Yes' from a web form checkbox to input into the database (and populate in the cms)

<input name="DirectMail" type="checkbox" value="Yes">

would be correct,

However, from memory, having done this many years ago, should we set the checked value to "1" for yes and "0" for No on the web form, even though the checked value is set to Yes in cmsb.

By gregThomas - November 5, 2014

Hi Zaba,

The default labels for a check box field are yes and no, but the values stored in the CMS will always be 1 or 0. So with your example the correct layout would be:

<input name="DirectMail" type="checkbox" value="1"> Yes

Let me know if you have any questions.

Thanks,

Greg

Greg Thomas







PHP Programmer - interactivetools.com