DISPLAYING THE CURRENT VALUE OF A CHECKBOX OR RADIO BUTTON - Jun 1st, 2011


If you want to display the current values in a checkbox or radio button field when a member logs in to revise their
profile, you can take this advice offered by Jason Sauchuk from Interactive Tools:

A checkbox in CMS Builder can only store a value of either 1 or 0.

What you need to do is to display your form element as either selected or unselected based on the value currently stored
in the database. There are two solutions that you could use.

1) You can use a single check box. If a member had previously checked yes, the box on the form will be checked,
otherwise, it will be blank:



<tr>
<td >Your Question Goes Here:</td>
<td ">Check for "Yes" <br /> <input type="checkbox" name="your_field" value="1" <?php
if(@$_REQUEST['your_field']){echo "checked='checked'";}?> /> </td>
</tr>



2) The other option would be to use radio buttons for yes and no. This way they can only select 1:



<tr>
<td >Your Question Goes Here:</td>
<td ><input type="radio" name="your_field" value="1" <?php if(@$_REQUEST['your_field']){echo "checked='checked'";}?>
/> Yes please <br />
<input type="radio" name="your_field" value="0" <?php if(!@$_REQUEST['your_field']){echo "checked='checked'";}?>> No
Thanks</td>
</tr>




The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service