我正在尝试创建一个选择菜单,用户可以选择一个部门,然后选择该部门的员工。相关选择......
好的,这就是问题......我需要直接绑定到cfc,因为这样绑定:
<cfselect name="people" bind = "cfc:test.getPeople({department.value})" />
不工作。它什么都不做......这就是什么样的解释:
<cfselect name="department"
query="getDepartments"
display="deptname"
value="deptcode"
queryPosition = "below">
<option value = "">Select a Department</option>
</cfselect>
这里是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 ORDER BY b.LastName,
b.FirstName
</cfquery>
<!--- And return it --->
<cfreturn data>
</cffunction>
</cfcomponent>
我尝试这样做:
<cfselect name="people"
bind = "url:test.cfc?method=getPeople&returnFormat=json&dcode={department.value}"
display = "FullName" value = "IDNum"
BindOnLoad = "true" />
但这不起作用......得到解析错误..
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]
答案 0 :(得分:0)
除非提交了表单,否则表单没有定义department.value,因此您的绑定将无效。请将您的第二个cfselect(员工)放在cflayout中,并在“部门”cfselect的onchange事件中将表单提交给布局。您可以使用coldFusio.navigate()方法将您的部门表单提交到员工布局。