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

Option value with cfselect in CF10

New Here ,
Jun 08, 2012 Jun 08, 2012

Copy link to clipboard

Copied

Has anyone gotten <option> values to work with cfselet in CF10?

This example:

<cfform name="mycfform">

    <!--- 

        The States selector. 

        The bindonload attribute is required to fill the selector. 

    --->

    <cfselect name="state" bind="cfc:bindFcns.getstates()" bindonload="true">

        <option name="0">--state--</option>

    </cfselect>

    <cfselect name="city" bind="cfc:bindFcns.getcities({state})">

        <option name="0">--city--</option>

    </cfselect>

</cfform>

When adding the option value, it doesn't show up in CF10.

Views

1.0K

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

correct answers 1 Correct answer

Community Expert , Jun 09, 2012 Jun 09, 2012

By design, ColdFusion's binding apparatus actually takes over the task of populating the list of options. Your option tag does not come in through the bind. Hence, as far as binding is concerned, your option tag does not exist.

The solution is to include the first option, for example, '--state--', in the return value of the bind. That is precisely what is done in the Coldfusion documentation. See the example bindFcns.cfc in the documentation on cfselect. There you will find:

<cffunction name="gets

...

Votes

Translate

Translate
Community Expert ,
Jun 09, 2012 Jun 09, 2012

Copy link to clipboard

Copied

By design, ColdFusion's binding apparatus actually takes over the task of populating the list of options. Your option tag does not come in through the bind. Hence, as far as binding is concerned, your option tag does not exist.

The solution is to include the first option, for example, '--state--', in the return value of the bind. That is precisely what is done in the Coldfusion documentation. See the example bindFcns.cfc in the documentation on cfselect. There you will find:

<cffunction name="getstates" access="remote">

<!--- I added the var--->

<cfset var state = arraynew(2)>

<cfset var xmlData = getXmlData()>

<cfset var numStates = 0>

<cfset state[1][1] = "0">

<cfset state[1][2] = "--state--">

<cfset numStates = ArrayLen(xmlData.states.XmlChildren)>

<cfloop from="1" to="#numStates#" index="j">

    <cfset state[j+1][1] =

        ltrim(xmlData.states.state.XmlAttributes.abr)>

    <cfset state[j+1][2] = ltrim(xmlData.states.state.name.xmlText)>

</cfloop>

<cfreturn state>

</cffunction>

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
New Here ,
Jun 09, 2012 Jun 09, 2012

Copy link to clipboard

Copied

LATEST

Ok, thanks.  It appears that the livedocs just need some editing as that is where I pulled that example from:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_r-s_14.html

Granted, it is CF8/CF9, but I tried this method on CF8 and it didn't work either.

I went ahead and created a union in query to add the rows, which is probably the better solution anyway.

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