• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

displaying cfselect option selected

Explorer ,
Apr 11, 2008 Apr 11, 2008

Copy link to clipboard

Copied

I have a CF form with a <cfselect> dropdown menu for a user to select an option. This is put into the db without a problem. However, I have another page that allows the user to edit the information for the record, on which all the data for that record is filled into the form fields. I tried putting a simple (but long)
<cfif entry.column IS "thevalue">
<option value="thevalue" selected="selected">The Value</option>
<cfelse>
<option value="thevalue">The Value</option>
</cfif>

and then I repeat this for all the possible options in the dropdown menu. Yet when the user goes to the edit form page, the first option is the option that is always selected (basically, it is NOT selecting the appropriate option). anyone see an error in my thinking or know a simpler way to make the selected="selected" value set without running many (many) cfif statements?
TOPICS
Advanced techniques

Views

543

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 11, 2008 Apr 11, 2008

Copy link to clipboard

Copied

This,
<cfif entry.column IS "thevalue">
is comparing a variable to a string literal. That might not be what you had in mind.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2008 Apr 11, 2008

Copy link to clipboard

Copied

LATEST
actually i forgot, i had tried it this way as well with the same (lack of) results:
<cfif TRIM(entry.column) IS "thevalue">

if i change the dropdown to just an input field, it displays the correct value, but i need it to look the same as the original form.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation