Solved

How do you display a checked a radio button data from the table into a form when the field is 'YES'

Posted on 2013-06-13
5
661 Views
Last Modified: 2013-07-03
Hello,

I have a ColdFusion form and SQL Database.   It's working fine. So when the user login, i'm able to display his data from the table into a textarea but I wasn't able to display the radio button checked and checkbox button checked.

so let start with the radio button and I will post another question for the checkbox.

reading_yes --> My form, when i load my form into my browser it show "YES" instead of the button checked
                                    (X) yes ( )no

This is the code.

 <td colspan="2" height="5" width="100%"><cfoutput>#DisplayCVIToolvolunteer.contactme#<cfinput type="radio" name="contactMe" id="contactMeYes" value="Yes" required="true" message="Question 1: This field is required. Please select yes or no. Please try again." onClick="checkme(this);" />
                &nbsp;
                <label for="ContactMeYes">Yes</label>
                <cfinput type="radio" name="contactMe" id="contactMeNo" value="No" onClick="checkme(this);" />
                No
                </label>
                &nbsp;&nbsp;<br>
                <div id="specify" style="display:none;">
                  <label>Please specify:
                    <input type="text" name="ContactMeSpecify" id="ContactMeSpecify" value="" maxlength="255" size="30" style="width: 200px;border:red 1px solid;">
                  </label>
                  <p id="error" style="color:red;display:none;">Required input! Or else... click "No" above...</p>
                </div></cfoutput></td>

Open in new window

SQL-Table-data.jpg
display-data.jpg
reading-yes.jpg
0
Comment
Question by:koila
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 39245936
Use cfinput's "checked" attribute:

<cfinput type="radio" name="contactMe" value="Yes"
      checked="#DisplayCVIToolvolunteer.contactme eq 'Yes'#" ..../>  Yes
<cfinput type="radio" name="contactMe" value="No"
      checked="#DisplayCVIToolvolunteer.contactme eq 'no'#" ..../>  No
0
 
LVL 4

Author Comment

by:koila
ID: 39248241
Hello Agx,

Thank you for your note, I've add the code and I've loaded the form so the yes button didn't came checked according to the table entry? why.

(*) yes (no)

The contactme field char10, not null

contactme
Yes

Thank you for your time,
0
 
LVL 4

Author Comment

by:koila
ID: 39248247
this is my code

<table border="0" cellspacing="0" cellpadding="0" width="100%" class="qtable">
            <tr>
              <td colspan="2" height="5" width="100%"><cfinput type="radio" name="contactMe" id="contactMeYes" value="Yes" checked="#DisplayCVIToolvolunteer.contactme eq 'Yes'#" required="true" message="Question 1: This field is required. Please select yes or no. Please try again." onClick="checkme(this);" />
                &nbsp;
                <label for="ContactMeYes">Yes</label>
                <cfinput type="radio" name="contactMe" id="contactMeNo" value="No" checked="#DisplayCVIToolvolunteer.contactme eq 'no'#" onClick="checkme(this);" />
                No
                </label>
                &nbsp;&nbsp;<br>
                <div id="specify" style="display:none;">
                  <label>Please specify:
                    <input type="text" name="ContactMeSpecify" id="ContactMeSpecify" value="" maxlength="255" size="30" style="width: 200px;border:red 1px solid;">
                  </label>
                  <p id="error" style="color:red;display:none;">Required input! Or else... click "No" above...</p>
                </div></td>
            </tr>
          </table>

Open in new window

0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 39248925
> The contactme field char10, not null

The only values in that column are "YES" or "NO", right?  

It could be that it's a CHAR field.  That'll add extra spaces to the query value.  Try trimming the value first:

<cfset trimmedValue = trim(DisplayCVIToolvolunteer.contactme)>
<cfoutput>
Debug:  #trimmedValue#  Length = #len(trimmedValue)#<br>
</cfoutput>
<cfinput type="radio" name="contactMe" value="Yes"
      checked="#trimmedValue eq 'Yes'#" ..../>  Yes
<cfinput type="radio" name="contactMe" value="No"
      checked="#trimmedValue eq 'no'#" ..../>  No


BTW: CHAR is a good choice when the values are always the same fixed size. For example, for storing UUID's. If the value lengths can vary, VARCHAR is usually a better choice.
0
 
LVL 4

Author Comment

by:koila
ID: 39297430
thank you.
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question