| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 712 人关注过本帖
标题:问题:二级联动
只看楼主 加入收藏
与寻
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-10-11
收藏
 问题点数:0 回复次数:1 
问题:二级联动

一个二级联动代码,在网上档的。运行出现问题,本来是二级联动,那时能用,我改成了三级联动,可是班级的下拉矿不能显示。请大家指点。。。
javaScript:
function findObject(fName,initValue)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST","serch.jsp?findObject="+fName+"&initValue="+initValue,false);
xmlhttp.send();
document.getElementById(fName).innerHTML=bytes2BSTR(xmlhttp.responsebody);
}
vbScript:
Function bytes2BSTR(vIn)
dim i
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function

serch.jsp
if(request.getParameter("findObject")!=null)
{
if (request.getParameter("findObject").equals("college"))
{
ResultSet rs = null;
try
{
out.print("<select name='college' onchange=javascript:findObject('special',this.value)>");

String sql = "select * from college ";
DataBase db = new DataBase();
db.connect();
db.stmt = db.conn.createStatement();
rs=db.stmt.executeQuery(sql);
while(rs.next()){
out.print( "<option value='' selected> </option>"+"<option value='"+rs.getString("c_num")+"'>"+new String(rs.getString("c_name").getBytes("ISO8859-1"))+"</option>");
}
out.print("</select>");
}
catch (Exception e){
}
finally{
try{
if (rs != null)
rs.close();

}
catch (Exception e){
e.printStackTrace();
}
}
}
if (request.getParameter("findObject").equals("special"))
{
ResultSet rqs = null;
try{

out.print("<select name='special' onchange=javascript:findObject1('class',this.value)>");


String sql = null;
if (request.getParameter("initValue").equals(""))
{
sql = "select * from sepcial";
}
else
{
sql = "select * from special where c_num='"+request.getParameter("initValue")+"'";
}
DataBase db = new DataBase();
db.connect();
db.stmt = db.conn.createStatement ();
rqs=db.stmt.executeQuery(sql);
while(rqs.next())
{
out.print("<option value='"+rqs.getString("sp_num")+"'>"+new String(rqs.getString("sp_name").getBytes("ISO8859-1"))+"</option>");
}
out.print("</select>");
}
catch (Exception e)
{
}
finally{
try{
if (rqs!= null)
rqs.close();

}
catch (Exception e){
e.printStackTrace();
}
}

}
if (request.getParameter("findObject").equals("class"))
{
ResultSet rqs = null;
try{

out.print("<select name='class' >");


String sql = null;
if (request.getParameter("initValue").equals(""))
{
sql = "select * from class";
}
else
{
sql = "select * from class where sp_num='"+request.getParameter("initValue")+"'";
}
DataBase db = new DataBase();
db.connect();
db.stmt = db.conn.createStatement ();
rqs=db.stmt.executeQuery(sql);
while(rqs.next())
{
out.print("<option value='"+rqs.getString("cl_num")+"'>"+new String(rqs.getString("cl_name").getBytes("ISO8859-1"))+"</option>");
}
out.print("</select>");
}
catch (Exception e)
{
}
finally{
try{
if (rqs!= null)
rqs.close();

}
catch (Exception e){
e.printStackTrace();
}
}

}
}
%>

<script language=vbscript src="bytetostr.js"></script>
<script language=javascript src="main.js"></script>


所属行业:<br>
<div id="college"></div>
所属明细行业:<br>
<div id="special"></div>
班级:
<div id="class"></div>

<script language="javascript">
findObject("college","");
findObject("special","");

findObject("class","");

</script>

搜索更多相关主题的帖子: Microsoft xmlhttp fName initValue 
2007-09-24 17:24
与寻
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-10-11
收藏
得分:0 
怎么没有人说说阿,好等啊.................
2007-09-25 21:38
快速回复:问题:二级联动
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014871 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved