Link to home
Start Free TrialLog in
Avatar of koila
koilaFlag for Australia

asked on

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

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
Avatar of _agx_
_agx_
Flag of United States of America image

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
Avatar of koila

ASKER

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,
Avatar of koila

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of koila

ASKER

thank you.