联动菜单存入数据库

clearxixi 2006-02-17 09:47:31
用js写了一个二级联动菜单,在jsp文件中,但是在存入数据库的时候,数据库里的都是id,也就是下拉框在数据库中的id,而不是她真正的文本串,请问怎么存,或这么写这个程序,才能使它是真正的文本串呢?javascript如下:
<html>
<head>
<title>后台产品添加</title>
<meta http-equiv=Content-Type content=text/HTML; charset=gb2312>
<link href=../INC/Style.Css rel=stylesheet type=text/css>
<script language = javascript>
var onecount;
onecount=0;
subcat = new Array();
<%
int count = 0;
rs = Conn.executeQuery(select * from ego_smallsort order by Sid);//读取数据
while(rs.next())
{
String sname=new String(rs.getString(Sname).getBytes(GBK),ISO8859_1);//转换字符类型
%>
subcat[<%=count%>] = new Array(<%=sname%>,<%=rs.getInt(Bid)%>,<%=rs.getInt(Sid)%>);//产生数组
<%
count = count + 1;
}
%>
onecount=<%=count%>;
function changelocation(id)
{
document.form1.smallsortselect.length = 0;
var id=id;
var i;
document.form1.smallsortselect.options[0] = new Option('选择二级分类',');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == id)
{
document.form1.smallsortselect.options[document.form1.smallsortselect.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>
<select name=bigsortselect onChange=changelocation(document.form1.bigsortselect.options[document.form1.bigsortselect.selectedIndex].value) size=1>
<option value=2>请选择一级分类</option>
<%
rs = Conn.executeQuery(select * from ego_bigsort order by Bid);
while(rs.next())
{
String Bname = new String(rs.getString(Bname).getBytes(GBK),ISO8859_1);
System.out.println(Bname);
%>
<option value=<%=rs.getInt(Bid)%>><%=Bname%></option>
<%
}
%>
</select><br>
</td>
</tr>
<br>
<tr>
<td height=20 align=right>选择二级分类:</td>
<td>
<select name=smallsortselect>
<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>
...全文
84 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧