2 qq 36128558 qq_36128558 于 2017.09.09 16:41 提问

Cannot read property 'length' of undefined问题

这是前台报的错误 sql我执行了有数据

 Uncaught TypeError: Cannot read property 'options' of null
    at replaceSelect (select_ui.js:917)
    at addSelect (select_ui.js:771)
    at initAllSelectUi (select_ui.js:728)
    at init (forwardNode.do?nodeName=StaffQuery:266)
    at wrappedFn (yahoo-dom-event.js:135)

应该是js哪个属性名错了把
这是js

 function queryTask(){
  YAHOO.util.Dom.setStyle("taskCont0","display","none");
  YAHOO.util.Dom.get("content0_message").innerHTML="<h2 class='default' onClick=\"ExChgClsName(this,'task0')\">员工信息</h2>";
  YAHOO.util.Dom.setStyle("taskCont0","display","");
  executeQuery(1,10);
}
//init on load
YAHOO.util.Event.addListener(window,'load',init);

2个回答

qq_24827217
qq_24827217   2017.09.09 23:06

options是null了能贴完整的代码吗,明显是你页面都没加载完就运行了js所以报异常

qq_36128558
qq_36128558   2017.09.11 08:56

<%@ page contentType="text/html;charset=GBK"%>


员工查询
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/meta_css.jsp"%>


namespace="/personManage">



员工查询条件






                    <td class="bgc_tt short">
                        员工姓名:
                    </td>
                    <td class="long">
                        <s:textfield name="userName" cssClass="input_v w_22"
                            ondblclick="getPersonByIns(this, 'StaffCode', '0,1', 'Y','0000','');"
                            onchange="code_CodeChange(this, 'StaffCode', '-1,0', 'Y','0000','');" />
                    </td>

                </tr>
                <tr>
                    <td class="bgc_tt short">
                        归属机构/部门代码:
                    </td>
                    <td class="long">
                        <s:textfield name="staffManageCondition.comCode" id="staffManageCondition.comCode"
                            cssClass="input_v w_22"
                            ondblclick="code_CodeSelect(this, 'ComcodeAndDepartment', '0,1', 'Y','0000','sales.personManage.personQuery');"
                            onchange="code_CodeChange(this, 'ComcodeAndDepartment', '0,1', 'Y','0000','sales.personManage.personQuery');" />
                    </td>
                    <td class="bgc_tt short">
                        归属机构/部门名称:
                    </td>
                    <td class="long">
                        <s:textfield name="comCName" cssClass="input_v w_22"
                            ondblclick="code_CodeSelect(this, 'ComcodeAndDepartment', '-1,0', 'Y','0000','sales.personManage.personQuery');"
                            onchange="code_CodeChange(this, 'ComcodeAndDepartment', '-1,0', 'Y','0000','sales.personManage.personQuery');" />
                    </td>
                </tr>

                <tr style="display: none;">
                    <td class="bgc_tt short">
                        归属团队代码:
                    </td>
                    <td class="long">

                        <s:textfield name="staffManageCondition.teamCode" id="staffManageCondition.teamCode" cssClass='input_v w_22'
                            ondblclick="checkQueryComCode(this, '1','1','TeamCodeByComOrDepartment')"
                            onchange="checkQueryComCode(this, '2','1','TeamCodeByComOrDepartment')"
                            />

                    </td>
                    <td class="bgc_tt short">
                        归属团队名称:
                    </td>
                    <td class="long">
                        <s:textfield name="teamName" cssClass="input_v w_22"
                            ondblclick="checkQueryComCode(this, '1','-1','TeamCodeByComOrDepartment')"
                            onchange="checkQueryComCode(this, '2','-1','TeamCodeByComOrDepartment')"
                            />
                    </td>
                </tr>
                <tr>
                    <td class="bgc_tt short">
                        岗位:
                    </td>
                    <td class="long" >
                    <div id="prpSstaffPositionAc" class="selectui-indiv">
                         <div class="selectConfig">
                               <div class="codeType">sysValue_StaffPosition</div>
                               </div>
                            <input id="prpSstaffPositionId" class="selectui-input" />
                              <s:hidden name="staffManageCondition.position" />
                            <div id="prpSstaffPositionId_Container" class="selectui-container"></div>
                    </div>

                    </td>

                    <td class="bgc_tt short">
                        效力状态:
                    </td>
                    <td class="long" >
                    <div id="prpScompanyValidStatusAc" class="selectui-indiv w_22">
                            <div class="selectConfig">
                                <div class="codeType">StaticSelect</div>
                            </div>
                            <s:select name="staffManageCondition.validStatus" id="validStatusId" cssClass="selectui-input w_13" 
                                list="#@java.util.LinkedHashMap@{'1':'在职','0':'离司'}"></s:select>
                            <div id="prpScompanyValidStatus_Container" class="selectui-container"></div>
                    </div>

                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <center>
                            <%-- 通用按钮 --%>
                            <input type="button" class="button_ty" name="bpmsubmit"
                                value="查询" onclick="queryTask();" />
                        </center>
                    </td>
                </tr>
            </table>
        </div>
        <div id="taskCont0" />
            <div id="content0_message"></div>
            <div id="task0">
                <div id="content0_navigation" class="query" align="left"></div>
                <div id="content0" class="sort"></div>
                <div id="content0_navigation" class="query" align="left"></div>
            </div>

        </div>
    </s:form>
</body>


<%@ include file="/common/i18njs.jsp"%>
<%@ include file="/common/meta_js.jsp"%>

var isFirstLoad = true; var contentDataTable; var contentColumnHeaders0; var tableHeader = { resultsList: "data", fields: ["PERSONID","PERSONNAME","COMNAME","TEAMNAME","VALIDSTATUS","VERIFYSTATUS","OPERATETIMES","OPERATETYPE","VERIFYTYPE"], totalRecords: "totalRecords" }; //YAHOO.namespace("query.container"); //Page Init function init(){ initAllSelectUi(); YAHOO.widget.Column.formatLink = function(elCell, oRecord, oColumn, oData) { switch(oColumn.key){ case "PERSONID": //elCell.innerHTML = oData +"<input type='hidden' name='personId' value='"+oData+"'/><input type='hidden' name='operateTimes' value='"+oRecord["OPERATETIMES"]+"'/>"; elCell.innerHTML = "<a href=\"#\" onclick=\"editRecord('${ctx}/staffManage/staffInfoView.do?modifyPersonId="+oData+"')\">"+ oData +"<input type='hidden' name='personId' value='"+oData+"'/><input type='hidden' name='operateTimes' value='"+oRecord["OPERATETIMES"]+"'/></a>"; break; case "isCheck": elCell.innerHTML ="<input type='checkbox' name='isCheck' value='"+oData+"' onclick=\"checkStatus(this,'"+oRecord["VALIDSTATUS"]+"','"+oRecord["OPERATETYPE"]+"','"+oRecord["VERIFYSTATUS"]+"');\">"; break; case "VALIDSTATUS": if(oRecord.VALIDSTATUS == 1){ elCell.innerHTML ="在职"; }else{ elCell.innerHTML ="离司"; } break; case "VERIFYSTATUS": if(oRecord.VERIFYSTATUS == '0'){ elCell.innerHTML ="暂存"; }else if(oRecord.VERIFYSTATUS == '9'){ elCell.innerHTML ="待审核"; } else if(oRecord.VERIFYSTATUS == '1'){ elCell.innerHTML ="审核通过"; } else if(oRecord.VERIFYSTATUS == '2') { elCell.innerHTML ="审核不通过"; } break; default: elCell.innerHTML = oData; } }; contentColumnHeaders0 =[ {key:"PERSONID",text:"员工代码",width:"30em",sortable:true,type:"link"}, {key:"PERSONNAME",text:"员工姓名",width:"50em",sortable:true,type:"link"}, {key:"COMNAME",text:"归属机构/部门名称",width:"50em",sortable:true,type:"link"}, {key:"VALIDSTATUS",text:"任职状态",width:"30em",sortable:true,type:"link"}, {key:"VERIFYSTATUS",text:"审核状态",width:"30em",sortable:true,type:"link"} ]; } //Query salesman Data function executeQuery(pageNo,pageSize){ if(isNaN(parseInt(pageNo))){ pageNo = 1; } if(isNaN(parseInt(pageSize))){ pageSize = 10; } var myColumnSet = new YAHOO.widget.ColumnSet(contentColumnHeaders0); var myDataSource = new YAHOO.util.DataSource("${ctx}/staffManage/staffListQuery.do"); myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; myDataSource.responseSchema = tableHeader; myDataSource.subscribe("responseParseEvent",SINOSOFT.util.navigation); myDataSource.connMgr.setForm(fm); var initialRequest = "pageSize="+pageSize+"&pageNo="+pageNo; var myConfiges ={ initialRequest:initialRequest, paginator:false }; contentDataTable = new YAHOO.widget.DataTable("content0",myColumnSet,myDataSource,myConfiges); } function queryTask(){ YAHOO.util.Dom.setStyle("taskCont0","display","none"); YAHOO.util.Dom.get("content0_message").innerHTML="<h2 class='default' onClick=\"ExChgClsName(this,'task0')\">员工信息</h2>"; YAHOO.util.Dom.setStyle("taskCont0","display",""); executeQuery(1,10); } //init on load YAHOO.util.Event.addListener(window,'load',init); function refreshPage(){ // window.submitDlg.hide(); window.fm.bpmsubmit.onclick(); } var submitDlg; function commitVerify() { var isChecks = document.getElementsByName("isCheck"); var personIds = document.getElementsByName("personId"); var operateTimes=document.getElementsByName("operateTimes"); var personId = ""; var operateTime=""; var selectFlag = false; for(var i = 0 ; i < isChecks.length ; i++){ if((isChecks[i].checked)){ personId+= personIds[i].value+","; operateTime+= operateTimes[i].value+","; selectFlag = true; } } if(!selectFlag){ alert("请选择要提交审核的员工"); return false; } if(confirm("确认要提交审核吗?")){ submitDlg = new YAHOO.widget.Panel("submitDlg",{iframe:true, visible:true, width:850, height:350, underlay:"shadow", constraintoviewport:true, fixedcenter:true, modal:true, zIndex:320}); submitDlg.setHeader("员工提交审核"); submitDlg.setBody("<iframe name='submitFrame' src='javascript:false;' frameborder='0' style='margin:0; padding:0; width:100%; height: 100%'></iframe>"); submitDlg.render(document.body); submitDlg.show(); YAHOO.util.Event.addListener(submitDlg.close, "click", submitDlg.close, this); fm.target="submitFrame"; fm.action=contextRootPath+"/staffManage/staffPassAudit.do?personIdSelected="+personId+"&operateTimesSelected="+operateTime; // 链接 fm.submit(); } else { } } function staffModify(personId,operateTimes){ var isChecks = document.getElementsByName("isCheck"); submitDlg = new YAHOO.widget.Panel("submitDlg",{iframe:true, visible:true, width:850, height:350, underlay:"shadow", constraintoviewport:true, fixedcenter:true, modal:true, zIndex:320}); submitDlg.setHeader("员工修改"); submitDlg.setBody("<iframe name='submitFrame' src='javascript:false;' frameborder='0' style='margin:0; padding:0; width:100%; height: 100%'></iframe>"); submitDlg.render(document.body); submitDlg.show(); YAHOO.util.Event.addListener(submitDlg.close, "click", submitDlg.close, this); fm.target="submitFrame"; fm.action=contextRootPath+"/staffManage/initStaffModify.do?modifyPersonId="+personId+"&modifyOperateTimes="+operateTimes; // 链接 fm.submit(); } function deleteStaff(personId,operateTimes){ submitDlg = new YAHOO.widget.Panel("submitDlg",{iframe:true, visible:true, width:850, height:350, underlay:"shadow", constraintoviewport:true, fixedcenter:true, modal:true, zIndex:320}); submitDlg.setHeader("员工删除"); submitDlg.setBody("<iframe name='submitFrame' src='javascript:false;' frameborder='0' style='margin:0; padding:0; width:100%; height: 100%'></iframe>"); submitDlg.render(document.body); submitDlg.show(); YAHOO.util.Event.addListener(submitDlg.close, "click", submitDlg.close, this); fm.target="submitFrame"; fm.action=contextRootPath+"/staffManage/staffDelete.do?modifyPersonId="+personId+"&modifyOperateTimes="+operateTimes; // 链接 fm.submit(); } function checkFindComCode(field,flag,codeType){ var comCodes=document.getElementsByName("staffManageCondition.comCode"); var comcode = comCodes[0].value; if(comcode == ''){ alert("请先选择归属机构代码"); fm.comCode.focus(); }else{ if(flag =='1'){ code_CodeSelect(field, codeType, '0,1', 'Y','0000','','staffManageCondition.comCode'); }else{ code_CodeChange(field, codeType, '0,1', 'Y','0000','','staffManageCondition.comCode'); } } } function getPersonByIns(field,codeType,flag){ var validStatusId = document.getElementById('validStatusId').value; code_CodeSelect(field, codeType, flag, 'Y',validStatusId); } function dataDown(){ fm.action=contextRootPath+"/staffManage/staffInfoExport.do"; // 链接 fm.submit(); }

员工代码:

cssClass="input_v w_22"
ondblclick="getPersonByIns(this, 'StaffCode', '0,1', 'Y','0000','');"
onchange="code_CodeChange(this, 'StaffCode', '0,1', 'Y','0000','');" />
Csdn user default icon
上传中...
上传图片
插入图片