2级菜单联动事例
2005-12-13 21:35
141 查看
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>2级菜单联动事例</title>
<meta http-equiv="Content-Type" content="text/HTML; charset=gb2312">
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
Connection con = DriverManager.getConnection("jdbc:sybase:Tds:166.111.1.1:5000/ynds", "sa", "");
//Connection conn= DriverManager.getConnection(url, "sa","");
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
int count = 0;
ResultSet rs = stmt.executeQuery("select * from taxempcode order by taxempcode");//读取数据
while(rs.next())
{
String taxempname=rs.getString("taxempname");//转换字符类型
%>
<!--三维数组-->
subcat[<%=count%>] = new Array("<%=taxempname%>","<%=rs.getString("taxorgcode")%>","<%=rs.getString("taxempcode")%>");//产生数组
<%
count = count + 1;
}
%>
onecount=<%=count%>;
function changelocation(id)
{
//alert(id)
document.form1.taxempselect.length = 0;
var id=id;
var i;
document.form1.taxempselect.options[0] = new Option('选择税务人员','');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == id)
{
document.form1.taxempselect.options[document.form1.taxempselect.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="form1" method="post" action="">
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="180" height="20" align="right">选择税务机关:</td>
<td width="320">
<!--onchange事件的值可以写为:document.form1.taxorgselect.value-->
<select name="taxorgselect" style="width:250px" onChange="changelocation(document.form1.taxorgselect.options[document.form1.taxorgselect.selectedIndex].value)" size="1">
<option value="2">请选择税务机关</option>
<%
rs = stmt.executeQuery("select * from taxorgcode order by taxorgcode");
while(rs.next())
{
String Bname = rs.getString("taxorgname");
//System.out.println(Bname);
%>
<option value="<%=rs.getString("taxorgcode")%>"><%=Bname%></option>
<%
}
rs.close();
stmt.close();
con.close();
%>
</select><br>
</td>
</tr>
<br>
<tr>
<td height="20" align="right">选择税务人员:</td>
<td>
<select name="taxempselect" style="width:250px">
<option value="" selected>请选择税务人员</option>
</select>
</td>
</tr>
<tr>
<td height="20" colspan="2" align="center"><input type="submit" name="Submit" value="提交"></td>
</tr>
<script LANGUAGE="JavaScript">
//changelocation(document.form1.bigsortselect.options[document.form1.bigsortselect.selectedIndex].value); //将一级分类的value传给changelocation()函数,生成二级分类的列表
</script>
</table>
</form>
</body>
</html>
<html>
<head>
<title>2级菜单联动事例</title>
<meta http-equiv="Content-Type" content="text/HTML; charset=gb2312">
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
Connection con = DriverManager.getConnection("jdbc:sybase:Tds:166.111.1.1:5000/ynds", "sa", "");
//Connection conn= DriverManager.getConnection(url, "sa","");
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
int count = 0;
ResultSet rs = stmt.executeQuery("select * from taxempcode order by taxempcode");//读取数据
while(rs.next())
{
String taxempname=rs.getString("taxempname");//转换字符类型
%>
<!--三维数组-->
subcat[<%=count%>] = new Array("<%=taxempname%>","<%=rs.getString("taxorgcode")%>","<%=rs.getString("taxempcode")%>");//产生数组
<%
count = count + 1;
}
%>
onecount=<%=count%>;
function changelocation(id)
{
//alert(id)
document.form1.taxempselect.length = 0;
var id=id;
var i;
document.form1.taxempselect.options[0] = new Option('选择税务人员','');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == id)
{
document.form1.taxempselect.options[document.form1.taxempselect.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="form1" method="post" action="">
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="180" height="20" align="right">选择税务机关:</td>
<td width="320">
<!--onchange事件的值可以写为:document.form1.taxorgselect.value-->
<select name="taxorgselect" style="width:250px" onChange="changelocation(document.form1.taxorgselect.options[document.form1.taxorgselect.selectedIndex].value)" size="1">
<option value="2">请选择税务机关</option>
<%
rs = stmt.executeQuery("select * from taxorgcode order by taxorgcode");
while(rs.next())
{
String Bname = rs.getString("taxorgname");
//System.out.println(Bname);
%>
<option value="<%=rs.getString("taxorgcode")%>"><%=Bname%></option>
<%
}
rs.close();
stmt.close();
con.close();
%>
</select><br>
</td>
</tr>
<br>
<tr>
<td height="20" align="right">选择税务人员:</td>
<td>
<select name="taxempselect" style="width:250px">
<option value="" selected>请选择税务人员</option>
</select>
</td>
</tr>
<tr>
<td height="20" colspan="2" align="center"><input type="submit" name="Submit" value="提交"></td>
</tr>
<script LANGUAGE="JavaScript">
//changelocation(document.form1.bigsortselect.options[document.form1.bigsortselect.selectedIndex].value); //将一级分类的value传给changelocation()函数,生成二级分类的列表
</script>
</table>
</form>
</body>
</html>
相关文章推荐
- 无限级联动菜单-AJAX版(附源码下载)
- js生成二级城市联动菜单,动态生成年、月、日字段,生产一个验证码
- js二级联动菜单
- 二级联动菜单
- 无限级联动菜单-AJAX版(附源码下载)
- android 商城左边菜单,右边联动
- 使用Django和MochiKit实现多级联动菜单
- 中国城市联动菜单
- asp.net中的联动菜单------使用客户端脚本JavaScript
- ASP二级分类联动菜单
- 【js与jquery】三级联动菜单的制作
- 【转】琥珀无限级联动菜单-AJAX版&JavaScript版。
- struts+jsp,利用javascript生成月日联动菜单(html:select html:option)
- ASP.NET利用JavaScript实现无刷新闪烁二级联动菜单
- 省市区三级联动菜单(附数据库)
- 用listview做联动菜单,省市区为例,附带省市区json文件
- 中国地区三级联动菜单(纯js制作)
- 二级联动菜单动态刷新下拉列表的一种实现方法
- 再谈 N 个 ASP.net DropDownList 无刷新联动菜单
- 使用javascript中读取Xml文件做成的一个二级联动菜单