2019独角兽企业重金招聘Python工程师标准>>>
//根据浏览器的类型创建xmlHttpRequest对象
function createXmlHttpRequest(){
if(window.ActiveXObject){
return new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest()){
return new XMLHttpRequest();
}
}
var xmlHttpRequest;
//异步响应函数
function search(para1,para2){
var url="/projectNameQuery.jsp?depid="+para1+"&projectType="+para2;
xmlHttpRequest=createXmlHttpRequest();
xmlHttpRequest.onreadystatechange=callback;
xmlHttpRequest.open("GET",url,true);
xmlHttpRequest.send(null);
}
//回调函数
function callback(){
var projectName=document.getElementById("projectname");
//请求被成功响应,已经接收到结果
if(xmlHttpRequest.readyState==4&&xmlHttpRequest.status==200){
var myJson = eval("(" + xmlHttpRequest.responseText + ")");
projectName.length=0;
projectName.options.add(new Option("请选择事项名称", "-1"));
for (i = 0; i < myJson.length; i ++) {
projectName.options.add(new Option(myJson[i].name, myJson[i].keyid));
}
} else {
projectName.length = 0;
projectName.options.add(new Option("请等待...","-1"));
}
}
function projectLoad(){
var url="/projectNameQuery.jsp?depid=-1&projectType=-1";
xmlHttpRequest=createXmlHttpRequest();
xmlHttpRequest.onreadystatechange=callback;
xmlHttpRequest.open("GET",url,true);
xmlHttpRequest.send(null);
}
//下拉框改变事件
function changeSelect(){
var zxdep=document.getElementById("zxdep");
var projectType=document.getElementById("projecttype");
var projectName=document.getElementById("projectname");
projectName.length=0;
if(zxdep.value==-1&&projectType.value==-1){
projectName.options.add(new Option("请选择事项名称","-1"));
}
else{
search(zxdep.value,projectType.value);
}
}
 
咨询部门:
事项类型:
事项名称:
<%@ page language="java" pageEncoding="GBK"%>
<%@ include file="/WEB-INF/include/getOatDBBean.jsp"%>
<%
String depId = request.getParameter("depid");
//String depId="2c90808e2aefd7cf012af40289830069";
String projectType = request.getParameter("projectType");
String whereSQL = "where 1=1";
String[][] result = null;
if(depId != null && projectType != null && !"-1".equals(depId) && !"-1".equals(projectType)){
whereSQL += " and t.xmlx='"+projectType+"'and t.department_id='"+depId+"' ";
}
if(depId!=null&&projectType!=null&&!"-1".equals(depId)){
whereSQL += " and t.department_id='"+depId+"' ";
}
if(depId!=null&&projectType!=null&&!"-1".equals(projectType)){
whereSQL += " and t.xmlx='"+projectType+"'";
}
String sql = "select t.keyid,t.name from projectinfo t "+whereSQL;
String callback = "[";
try{
result = otaDbbean.getManyRows_ManyColumns(sql);
for(int i=0; i
三级联动通过ajax查询数据库实现