我在一个函数 (2) 中构建一个选择,然后在另一个函数 (1) 中调用它,我在其中传递构建函数所需的值并选择适当的批准者。除了将html传回函数(1)之外,一切正常。
功能(1)
function loadTravelRules(id){
$.ajax({type: "GET",url: "CFCs/myapprovers.cfc",dataType: "json",data: {method: "MYAPPROVERS_RLUz",MYAPPROVERSID: id
},success: function(response){
var rdata = response.DATA;
var str = '<ul>';
for (var i = 0; i < rdata.length; i++) {
var aid = response.DATA[i][response.COLUMNS.indexOf('MYAPPROVERSID')];
var auditor = response.DATA[i][response.COLUMNS.indexOf('DEPTAUDITAPPROVEREMPLID')];
var firstApprover = response.DATA[i][response.COLUMNS.indexOf('FIRSTAPPROVEREMPLID')];
var secondApprover = response.DATA[i][response.COLUMNS.indexOf('SECONDAPPROVEREMPLID')];
var thirdApprover = response.DATA[i][response.COLUMNS.indexOf('THIRDAPPROVEREMPLID')];
var firstDivApprover = response.DATA[i][response.COLUMNS.indexOf('FIRSTDIVAPPROVEREMPLID')];
var secondDivApprover = response.DATA[i][response.COLUMNS.indexOf('SECONDDIVAPPROVEREMPLID')];
var deptOverRide = response.DATA[i][response.COLUMNS.indexOf('DEPTOVERRIDEEMPLID')];
var title = response.DATA[i][response.COLUMNS.indexOf('APPROVALRULE')];
var auditorSelect = deptApproverSelect(id=aid,nameType="timekeeper",eid=auditor);
str += '<li>Auditor: '+auditorSelect+'</li>';
str += '<li>First Approver: '+firstApprover+'</li>';
str += '<li>Second Approver: '+secondApprover+'</li>';
str += '<li>Third Approver: '+thirdApprover+'</li>';
str += '<li>First Div. Approver: '+firstDivApprover+'</li>';
str += '<li>Second Div. Approver: '+secondDivApprover+'</li>';
str += '<li>Dept. Override: '+deptOverRide+'</li>';
}
str += '</ul>';
$('#manageApprovers').dialog({
title: title+' Rules',
modal:true
}).html(str);
}
})
}
功能(2)
function deptApproverSelect(id,nameType,eid){
var deptid = <cfoutput>#qGetMyDept.DIV_DEPARTMENTID#</cfoutput>;
$.ajax({type: "GET",url: "CFCs/approvers.cfc",dataType: "json",async: false,data: {method: "DEPTAPPROVER_RLUz",deptid: deptid
},success: function(response){
var data = response.DATA;
var selectApprover = '<select id="'+nameType+'_'+id+'" name="'+nameType+'">';
selectApprover += '<option value="" selected="selected">Select Approver</option>';
for (var i = 0; i < data.length; i++) {
var display = response.DATA[i][response.COLUMNS.indexOf('FULL_NAME')];
var emplid = response.DATA[i][response.COLUMNS.indexOf('EMPLID')];
if(emplid==eid){
var selected = 'selected="selected"';
}else{
var selected = '';
}
selectApprover += '<option value="'+emplid+'"'+selected+'>'+display+'</option>';
}
selectApprover += '</select>';
console.log(selectApprover)
}
})
}
提前致谢