<html>
<table>
<tr>
<td height="22"><div align="center">名称:</div></td>
<td width="26%" align="left" ><div align="left">
<select name="dw" onChange='selec(this.value,"1")'>
<option selected value="-1">--请选择--</option>
<%
ResultSet rs = null;
Connection con = read.getLj();
String sql = "select distinct * from tbl_department where [DWBH]>='00' and [SJDW]='-1'";
try {
rs = operate.executeQuery(con, sql);
} catch (Exception e) {
e.printStackTrace();
}
while (rs.next()) {
String bh = rs.getString("BH").trim();
String mc = rs.getString("MC").trim();
out.println("<option value='"+bh+"'>" + mc + "</option>");
}
read.free(con);
%>
</select>*
</div></td>
<td width="18%" align="left" ><div id="dw2" style="display:none"><select name="sel2" id="sel2" onChange='selec(this.value,"2")'>
<option value="-1">--请选择--</option>
</select></div></td>
<td width="20%" align="left" ><div id="dw3" style="display:none"><select name="sel3" id="sel3" onChange='selec(this.value,"3")'>
<option value="-1">--请选择--</option>
</select></div></td>
<td width="21%" align="left" ><div id="dw4" style="display:none"><select name="sel4" id="sel4" onChange='selec(this.value,"4")'>
<option value="-1">--请选择--</option>
</select></div></td>
</tr>
</table>
</html>
<script type="text/javascript">
var xmlhttp;
var data;
function createXMLHttpRequest()
{
// 如果是IE浏览器,采用该方式生成XMLHttpRequest对象
if(window.ActiveXObject)
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
}
function selec(parm,parm2){
t_mp=parm2;
g=++t_mp;
//alert(g+t_mp);
while(g<5){
dws="dw"+g;
dwt="sel"+g;
var dw=document.getElementById(dws);
var se=document.getElementById(dwt);
dw.style.display=(dw.style.display =="none")?"none":"none";
se.options[se.selectedIndex].value="-1";
g++;
}
if(parm=="-1")
{
return;
}else{
var url="reg_action.jsp?parm="+escape(parm);
createXMLHttpRequest();
xmlhttp.onreadystatechange = handleStateChange;
xmlhttp.open("GET",appendTimestamp(url),true);
xmlhttp.send(null);
}
}
function appendTimestamp(url)
{
if (url.indexOf("?")>0)
{
return url+"&ajax_time="+new Date().getTime();
} else
{
return url+"?ajax_time="+new Date().getTime();
}
}
function handleStateChange()
{
if(xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
data=xmlhttp.responseText;
da_ta=data.split(",");
dwstr="dw"+t_mp;
var dw=document.getElementById(dwstr);
sestr="sel"+t_mp;
var se=document.getElementById(sestr);
count=da_ta.length;
//alert(count);
if(count!=1){
dw.style.display=(dw.style.display =="none")?"block":"block";
}else{
dw.style.display=(dw.style.display =="none")?"none":"none";
}
for(i=0;i<(count-1)/2;i++){
se.options[i+1]=new Option(da_ta[(count-1)/2+i],da_ta[i]);
}
if(i<=se.options.length){
se.options.length=i+1;
}//if
}//if(xmlhttp.status == 200)
}//if
}
</script>