0

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)

        }
    })
}

前もって感謝します

4

1 に答える 1

0

問題が解決しました:

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')];
            str += '<li>Auditor: <span id="auditor"></span></li>';
            str += '<li>First Approver: <span id="firstApprover"></span></li>';
            str += '<li>Second Approver: <span id="secondApprover"></span></li>';
            str += '<li>Third Approver: <span id="thirdApprover"></span></li>';
            str += '<li>First Div. Approver: <span id="firstDivApprover"></span></li>';
            str += '<li>Second Div. Approver: <span id="secondDivApprover"></span></li>';
            str += '<li>Dept. Override: <span id="deptOverRide""></span></li>';
            }
         str += '</ul>';
         $('#manageApprovers').dialog({
            title: title+' Rules',
            width:330,
            modal:true
         }).html(str);
            deptApproverSelect(id=aid,nameType="auditor",eid=auditor);
            deptApproverSelect(id=aid,nameType="firstApprover",eid=firstApprover);
            deptApproverSelect(id=aid,nameType="secondApprover",eid=secondApprover);
            deptApproverSelect(id=aid,nameType="thirdApprover",eid=thirdApprover);
            deptApproverSelect(id=aid,nameType="firstDivApprover",eid=firstDivApprover);
            deptApproverSelect(id=aid,nameType="secondDivApprover",eid=secondDivApprover);
            deptApproverSelect(id=aid,nameType="deptOverRide",eid=deptOverRide);
        }
    })

}

function deptApproverSelect(id,nameType,eid){ var deptid = #qGetMyDept.DIV_DEPARTMENTID#; $.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 = ''; selectApprover += 'Select Approver'; 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 += ''+display+''; } selectApprover += ''; $('#'+nameType).html(selectApprover); } }) }

于 2013-08-21T17:05:38.227 に答える