开发者

How to bind a CFC directly to a select menu?

开发者 https://www.devze.com 2023-01-06 01:17 出处:网络
I\'m trying to create a select menu where one can select a department and then select employees in that department. Related Selects...

I'm trying to create a select menu where one can select a department and then select employees in that department. Related Selects...

Ok here is the problem...I need to bind directly to the cfc because binding like this:

<cfselect name="people" bind = "cfc:test.getPeople({department.value})" />

DOES NOT WORK. It does nothing... here is what deparment looks like:

<cfselect name="department"
        query="getDepartments"
        display="deptname"
        value="deptcode" 
        queryPosition = "below">
        <option value = "">Select a Department</option>
        </cfselect>

and here the cfc:

<cfcomponent>

    <cfset THIS.dsn="sqlProd_faculty_db">


    <!--- Get art by media type --->
    <cffunction name="getPeople" access="remote" returnType="query" >
        <cfargument name="dcode" type="any" required="true">

        <!--- Define variables --->
        <cfset var data="">


        <!--- Get data --->
        <cfquery name="data" datasource="#THIS.dsn#">
        SELECT  b.LastName + ', ' + b.FirstName AS FullName, p.IDNum FROM faculty.dbo.SACS_Person p, faculty.dbo.budPerson 
      b WHERE p.DeptCode = '#arguments.dcode#' AND p.IDNum = b.ID开发者_StackOverflow ORDER BY b.LastName, 
        b.FirstName
        </cfquery>


        <!--- And return it --->
        <cfreturn data>
    </cffunction>

</cfcomponent>

I tried doing it like this:

<cfselect name="people"
        bind = "url:test.cfc?method=getPeople&returnFormat=json&dcode={department.value}" 
        display = "FullName" value = "IDNum"
        BindOnLoad = "true" />

But that didn't work... get a parsing error..

Error parsing JSON response: 



<script language="javascript">

<!--

document.onkeydown = catchKey;

step1 = 0;

step2 = 0;



function catchKey(e){

   if(window.event.keyCode == 17){

      step1 = 1;

   }

   if(window.event.keyCode == 18){

      step2 = 1;

   }

   if(window.event.keyCode == 65){

      if(step1 && step2){

         newLevel = prompt("Level:", "new Level");

         step1 = 0; step2 = 0;

         gotostring = "./admin_macros.cfm?NewLevel=" + newLevel + "&Action=LevelChange";

         window.location = gotostring;

      }

   }

}

-->

</script>

{"COLUMNS":["FULLNAME","IDNUM"],"DATA":[]} [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]


The form does not have the department.value defined unless it is submitted and hence your bind will not work. Please have your second cfselect(employee) placed in a cflayout and have in your onchange event of the 'department' cfselect to submit the form to the layout. You can use the coldFusio.navigate() method to submit your depart ment form onto the employee layout.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号