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
614 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
  • 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now