Skip to main content
Inspiring
April 11, 2008
Question

displaying cfselect option selected

  • April 11, 2008
  • 1 reply
  • 629 views
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?
This topic has been closed for replies.

1 reply

Inspiring
April 11, 2008
This,
<cfif entry.column IS "thevalue">
is comparing a variable to a string literal. That might not be what you had in mind.
Inspiring
April 11, 2008
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.