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

Why won't cfselect fill the initial value?

Participant ,
Sep 09, 2009 Sep 09, 2009

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>

1.1K
Translate
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 ,
Sep 09, 2009 Sep 09, 2009

How many records does the state query return?

What is the value of url.form_action?

Shouldn't your cfselect have a value attribute?

Translate
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
Participant ,
Sep 09, 2009 Sep 09, 2009

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.

Translate
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
Participant ,
Sep 09, 2009 Sep 09, 2009

value= did not work.

Translate
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 ,
Sep 09, 2009 Sep 09, 2009

When in doubt, read the manual.  If you don't have one, google "cfselect".

Translate
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
Participant ,
Sep 09, 2009 Sep 09, 2009

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.

Translate
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 ,
Sep 09, 2009 Sep 09, 2009
LATEST

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

Translate
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