• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

Coldfusion Bound Dropdowns : Question

Hi,
I am using the Coldfusion Bind/AJAX feature to populate a second select list (dropdown) based on the choice from the first.  It works fine!!

My slight issue is that the 2nd (dependent) drop down list always starts off empty until the selection from the first list is made.

Q:  Is it possible on the initial load of the page to populate the 2nd list with a single entry like "**Refine Your Selection **" ?

I tried adding an HTML "Option statement to the 2nd list but it get's ignored.

Please advise.

Thanks,
hefterr
0
hefterr
Asked:
hefterr
  • 3
  • 2
1 Solution
 
_agx_Commented:
Unfortunately, you have to add that option to whatever query you're using to populate the list.  What d

Say this was your list
<cfselect name="yourSecondList"
   bind="cfc:yourCFC.geItems({nameOfFirstList})" value="recordID" display="nameColumn" />

You'd have to add an empty option to the query in your CFC. Replace the "0" RecordID with whatever value should represent (no selection made yet)

<cffunction name="geItems" access="remote" returnType="query">
      <cfargument name="idFromFirstList" type="any" required="true">

      ....etc...

      <cfquery ....>
           SELECT 1 AS SortCol, recordID, NameColumn FROM YourTable
           UNION ALL
           SELECT 0 AS SortCol, 0 AS RecordID, '**Refine Your Selection **' AS NameColumn
          ORDER BY SortCol
       </cfquery>

       .... etc....
</cffunction>
0
 
hefterrAuthor Commented:
Hi aqx,
The problem is that the 2nd list query doesn't run until a selection is made from the first.  So on the initial page load (before a slection is made) I have no controlover the contents of the 2nd dropdown list content (it seems).

Thanks,
hefterr
0
 
_agx_Commented:
Yes, but if you do make it bindonload the query I mentioned above will work.  
0
 
_agx_Commented:
ie

<cfselect name="yourSecondList"
   bindOnLoad="true"
   bind="cfc:yourCFC.geItems({nameOfFirstList})"
   value="recordID"
   display="nameColumn"   />
0
 
hefterrAuthor Commented:
aqx,
I'll give it a try.  Thanks.

hefterr
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now