Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CF Bind for cascading select boxes - experts only!

Posted on 2010-11-11
3
Medium Priority
?
962 Views
Last Modified: 2012-06-27
Hi Experts,

I'm running CF9 and I figured instead of using an old custom tag to mimic ajax functionality, I wanna use cf bind, which makes life much easier for me (I don't have to deal with all the html nuisance with the old custom tag). On change of the first select box should trigger the bind in the lower two select boxes. The only thing is that I have several cascading select boxes that need to be bound using bind, but they are all in a block that can be refreshed using a check box that uses the old custom tag. Can I have that functionality remain the same but change the select boxes to use bind? Or would that create a conflict because the area in which the cascading select boxes are in a dynamically generated block? If so, could someone give me some leads on how to do the binds?Code is below, thanks in advance!
<!---my select boxes--->
<select name="HRType" id="optype">
  <option value="">All</option>
   <option value="Process">Process</option>
   <option value="Action">Action</option>
</select>

<!---this is the first cascading box that needs to be bound to the one above--->
<select name="ProcessType">
   <option value="">All</option>
  <cfoutput query="GetProcType" group="ProcType">
    <optgroup label="#oType#">
      <cfoutput>
        <option value="#dataid#">#text#</option>
      </cfoutput>
   </cfoutput>
</select>
<!---this select box is also bound to the first select box but with different values--->
<select name="subgroup" id="subgroup">
<option value="">All</option>
<cfoutput query="GetHop" group="aid">
<option value="#aid#">#group#</option>
</cfoutput>
</select>
<!---I know that select has to be changed to cfselect but this is what I have right now. Here is what I have in my cfc - myCFC.cfc --->

<cfcomponent>
  
<cffunction name="myFunc" access="remote" returnformat="plain">
	<cfargument name="ho" required="Yes" default="">
	<cfargument name="site" required="Yes" default="">
	<cfargument name="on" required="Yes" default="">
	<cfargument name="lc" required="Yes" default="">
	<cfargument name="org" required="Yes" default="">
	<cfargument name="ln" required="Yes" default="">
	
	<cfquery name="GetProcType" datasource="#odbc#">
	Select *
	FROM rTable WITH (NOLOCK) 
	where 
	<cfif arguments.ho neq "" or arguments.ho neq "all">
		rtable.id = #arguments.ho# and 
	</cfif>
	rTable.site = #arguments.site#

	</cfquery>
	
	<cfquery name="GetHop" datasource="#odbc#">
		Select * from pTable
		DO = '#arguments.on#'
		
	</cfquery>
	
	<cfset myStruct = StructNew()>
        <cfset myStruct.firstSelectBox = ValueList(GetProcType.name)>
        <cfset myStruct.secondSelectBox = ValueList(GetHop.text)>
          
<cfreturn myStruct>
</cffunction>
</cffunction>

Open in new window

0
Comment
Question by:roger_v
[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
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
docnica earned 1500 total points
ID: 34170728

ok a bind with cfselect looks like this:

<cfselect tabindex="6" name="IDModelo" bind="cfc:datos.getModelo({IDMarca})" class="ui-autocomplete-input ui-widget ui-widget-content ui-corner-all" style="width:200px;" />

datos is the name of the cfc

getModelo is the name of the function

IDMarca, is the ID you pass from the parent select box and must match the name of the selectbox. So in your case, the HRType select box

<select name="ProcessType"  bind="cfc:nameofcfc.myFunc({HRType})">

binded selectboxes are filled by the cfc, so as you see in mine, you do not need to use cfoutput and option tags.

the function would look like this

<!--- obtenemos los modelos de vehiculos --->
   <cffunction name="getModelo" access="remote" returnType="array">
      <cfargument name="IDMarca" type="numeric" required="true">

      <!--- Define variables --->
      <cfset var data="">
      <cfset var result=ArrayNew(2)>
      <cfset var i=0>

      <!--- Get data --->
      <cfquery name="data" datasource="#THIS.dsn#">
      SELECT IDModelo, Modelo
      FROM Modelo
      WHERE IDMarca = #ARGUMENTS.IDMarca#
      ORDER BY Modelo
      </cfquery>
   
      <!--- Convert results to array --->
      <cfloop index="i" from="1" to="#data.RecordCount#">
         <cfset result[i][1]=data.IDModelo[i]>
         <cfset result[i][2]=data.Modelo[i]>
      </cfloop>

you can bind whatever quantity of select boxes to the same parent, so if you need 2 or 3 select boxes to change based on one, just pass the ID

Open in new window

0
 
LVL 4

Expert Comment

by:docnica
ID: 34170730
sorry i posted everithing as code, but for some reason the site gave me errors the normal way
0
 
LVL 1

Author Closing Comment

by:roger_v
ID: 34278645
Although this didn't address my exact issue, it did give me some pointers
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

730 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