We help IT Professionals succeed at work.

cfc issue

cfsatx asked
I am using the same cfc in 2 places in my cfm page to display the county code drop down values based on radio button clicks. It appears to populate fine in one place.
In the next place it doesn't populate the country codes. How do I make it work?
<cfselect name="countrycode" 
      bind="cfc:dmis.getCountry()" bindonload="true" 
      required="yes"  selected="US" style="width:200" />

Open in new window

Watch Question


Can't I use the same cfc multiple times in the same cfm page? Is this a flushing issue?

You can use the same CFC multiple times, are both SELECT tags exactly the same?  Except for the NAME of the select tag?
Just a guess here since you haven't supplied full code but are both your selects named countrycode

<cfselect name="countrycode">

if so that could be the issue


I tried changing the select name and used the same cfc function. it works now. Thanks,
Hmmm, that's what I said a full 2 minutes before Sid  :)
the name attribute of many cf tags actually gets translated to an ID when cf creates the html

<cfselect name="foo">

gets written as

<select id="foo">

and since ID's must be unique, the javascript that cf builds to run the select box will only be able to modify one. Usually the first on the page
"Hmmm, that's what I said a full 2 minutes before Sid  :)"

quite right! although it was more like 1:45 ;p

cfsatx click request attention and let admins know you want the q reopened to reassign pts.
Most Valuable Expert 2015

@cfsatx - As an aside... you seem to be doing a lot of ajax work. If you're using a development server, you should enable the ajax debugging console in the CF Admin.  Then you can view exactly what's happening with your ajax calls just by adding a "?cfdebug" onto your urls.  

1) CF Admin > Debugging & Logging > Debug Output Settings page >  Select the Enable Ajax Debug Log Window option

2) Add the debug parameter to any url