?
Solved

Coldfusion Bound Dropdowns : Question

Posted on 2010-01-09
5
Medium Priority
?
246 Views
Last Modified: 2013-12-24
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
Comment
Question by:hefterr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 26274506
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
 
LVL 1

Author Comment

by:hefterr
ID: 26275249
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
 
LVL 52

Expert Comment

by:_agx_
ID: 26275291
Yes, but if you do make it bindonload the query I mentioned above will work.  
0
 
LVL 52

Expert Comment

by:_agx_
ID: 26275304
ie

<cfselect name="yourSecondList"
   bindOnLoad="true"
   bind="cfc:yourCFC.geItems({nameOfFirstList})"
   value="recordID"
   display="nameColumn"   />
0
 
LVL 1

Author Comment

by:hefterr
ID: 26275360
aqx,
I'll give it a try.  Thanks.

hefterr
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question