1 つの関数 (2) で選択を構築し、別の関数 (1) でそれを呼び出して、関数を構築し、適切な承認者を選択するために必要な値を渡します。html を function(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)
}
})
}
前もって感謝します