Membership plugin - Echo current value of checkbox
3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: October 18, 2010 (RSS)
Hi All,
I’ve set up some checkboxes on a membership plugin user profile form.
When a member wants to revise their profile, I show the current value of the text fields in the form using
I’m stuck on how to echo the existing value of the checkboxes so that the member can see the current value when they want to revise their options.
Here’s the code that I’m using in the “add record” section”:
and in the form:
If someone has done this before, could you pass along the secret?
Thanks for your help,
Jerry Kornbluth
I’ve set up some checkboxes on a membership plugin user profile form.
When a member wants to revise their profile, I show the current value of the text fields in the form using
value="<?php echo htmlspecialchars(@$_REQUEST['my_field']) ?>".
I’m stuck on how to echo the existing value of the checkboxes so that the member can see the current value when they want to revise their options.
Here’s the code that I’m using in the “add record” section”:
share = '".mysql_real_escape_string( $_REQUEST['share'] )."',
and in the form:
<tr>
<td class="body-text-bold-9" valign="top">Can we share your e-mail address with other Art organizations</td>
<td class="body-text-9" valign="top"><input type="checkbox" name="share" value="1"> Yes please<br />
<input type="checkbox" name="share" value="0"> No Thanks<br /></td>
</tr>
If someone has done this before, could you pass along the secret?
Thanks for your help,
Jerry Kornbluth
The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Membership plugin - Echo current value of checkbox
By Jason - October 18, 2010
Hi Jerry,
A checkbox in CMS Builder can only store a value of either 1 or 0. However, in your form you're using 2 check boxes. The problem with this is that there is nothing to prevent a user from checking both.
What you need to do is to display your form element as either selected or unselected based on the value currrently stored in the database. There are two solutions that you could use.
1) You can use a single check box to allow them to decide if they want to share their email address or not. If they had previously checked yes, the box on the form will be checked, otherwise, it will be blank:
2) The other option would be to use radio buttons for yes and no. This way they can only select 1:
The second solution is probably closer to what you are currently trying.
Hope this helps
A checkbox in CMS Builder can only store a value of either 1 or 0. However, in your form you're using 2 check boxes. The problem with this is that there is nothing to prevent a user from checking both.
What you need to do is to display your form element as either selected or unselected based on the value currrently stored in the database. There are two solutions that you could use.
1) You can use a single check box to allow them to decide if they want to share their email address or not. If they had previously checked yes, the box on the form will be checked, otherwise, it will be blank:
<tr>
<td class="body-text-bold-9" valign="top">Share my e-mail address with other Art organizations:</td>
<td class="body-text-9" valign="top"><input type="checkbox" name="share" value="1" <?php if(@$_REQUEST['share']){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 class="body-text-bold-9" valign="top">Can we share your e-mail address with other Art organizations</td>
<td class="body-text-9" valign="top"><input type="radio" name="share" value="1" <?php if(@$_REQUEST['share']){echo "checked='checked'";}?> /> Yes please<br />
<input type="radio" name="share" value="0" <?php if(!@$_REQUEST['share']){echo "checked='checked'";}?>> No Thanks<br /></td>
</tr>
The second solution is probably closer to what you are currently trying.
Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Membership plugin - Echo current value of checkbox
Thanks Jason.
Appreciate the help!
Jerry
Appreciate the help!
Jerry
The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php