Copy link to clipboard
Copied
I don't understand why the cfselect won't put in the initial value...
<cfif #URL.form_action# EQ "update">
<cfquery name="details">
GET STATE QUERY
</cfquery>
<cfselect selected="#details.state#" name="states" bind="cfc:_kpcfc_select.get_states()" bindonload="true" required="yes" message="Please select the state."/><span class="red">*</span>
</cfif>
Copy link to clipboard
Copied
How many records does the state query return?
What is the value of url.form_action?
Shouldn't your cfselect have a value attribute?
Copy link to clipboard
Copied
Query returns one record. But I need it to be selected at first, and then the user will have the option to select a different one.
url.form_action = "update"
I thought it was "selected" I needed to enable... let me try "value=" instead.
Copy link to clipboard
Copied
value= did not work.
Copy link to clipboard
Copied
When in doubt, read the manual. If you don't have one, google "cfselect".
Copy link to clipboard
Copied
Dude that is the worst response ever. I arrived at the forums after already reading this page: http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_r-s_14.html
Clearly the selected attribute is what I am supposed to use, however it does not work.
Please someone suggest a solution other than retracing my steps.
Copy link to clipboard
Copied
Dude that is the worst response ever. I arrived at the forums after already reading this page: http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_r-s_14.ht ml
Actually I think it's pretty good advice. There's nothing in your post to suggest you had already read the docs, and given the docs actually explain why what you're trying to do doesn't work, it's reasonable to assume you'd not read them.
Clearly the selected attribute is what I am supposed to use, however it does not work.
Well. Hmmm. You see the docs also say this:
"This attribute applies only if selection list items are generated from a query."
My emphasis. Your <cfselect> is generated from a bind attribute, not a query attribute. So that would be why it's "not working".
FWIW, this restriction seems to have been lifted in CF9. Not that that's much help to you, I imagine.
Please someone suggest a solution other than retracing my steps.
OK.
Suggestion 1: if someone takes the time to try to help you, don't be rude to them, even if you don't like their suggestion. It will not endear you to the people who are trying to help you, so you might find yourself not being helped.
Suggestion 2: I guess one approach would be to knock together some JS that runs after the form has rendered which scans down the option collection until it finds the item you want selected, then select it.
Suggestion 3: maybe just populate the select with a query instead of a bind.
--
Adam