日期:2014-05-18  浏览次数:20675 次

关于下拉菜单的问题
我用JSP做的一个手机库存系统,其中在入库时,其中有俩个下拉菜单,一个是手机类型(如摩托罗拉,三星)一个是手机型号(如L6,V360,x208),俩个下拉菜单的内容都从数据库中查询,如手机类型是rs.getstring(leixing),手机型号是用的rs.getstring(xinghao),现在遇到个问题就是如何在选择第一个下拉菜单时,如选择摩托罗拉则第二个自动只显示摩托罗拉的手机型号(如L6,v360),如选择三星则第二个下拉菜单只显示三星的手机型号,哪位高手能给指点指点该如何实现,或者是有更好的办法吗?

------解决方案--------------------
<html> <head>
<LINK href=Site.css rel=stylesheet>
<title> - 添加文章 </title>
</head>
<body topmargin= "0 ">
<jsp:include page= "../../top.jsp " />
<table border= "1 " width= "100% " align=center cellpadding= "0 " cellspacing= "0 " style= "border-collapse: collapse " bordercolor= " ">
<form name=form1 method= "get " action= "addarticle.goto.add.do ">
<tr align= "center ">
<td colspan= "1 " class= "TDtop " height=25>
<div align= "center " > ┊ <B> 添加文章--类别选择 </B> ┊ </div>
</td>
</tr>
<input type= "hidden " name= "typeid " value= " <bonc:param name= 'typeid '/> ">
<tr bgcolor= "#FFFFFF ">
<td align= "center ">
<p>   </p>
<p> 所属大类:
<select name= "bigclassid " onChange= "changelocation(this.value,this.form) " size= "1 ">
<option selected value= " "> 请选择大类 </option>
<bonc:options name= "bigclassOption "/>
</select>
所属小类:
<select name= "smallclassid " size= "1 ">
<option selected value= " "> 请选择小类 </option>

</select>
</p>
<p>   </p>
</td>
</tr>
<tr>
<td align= "center " height=25 class= "TDtop ">
<input type= "button " value= " 返 回 " name= "B1 " onclick=javascript:history.go(-1) style= "font-size: 9pt; color: #000000; background-color: #EAEAF4; solid #EAEAF4 " onMouseOver = "this.style.backgroundColor= '#ffffff ' " onMouseOut = "this.style.backgroundColor= '#EAEAF4 ' ">
<input type= "submit " value= " 继 续 " name= "B1 " style= "font-size: 9pt; color: #000000; background-color: #EAEAF4; solid #EAEAF4 " onMouseOver = "this.style.backgroundColor= '#ffffff ' " onMouseOut = "this.style.backgroundColor= '#EAEAF4 ' ">
</td>
</tr>
</form>
</table>
<jsp:include page= "../../bottom.jsp "/>
</body>
</html>
<script language = "JavaScript ">
var onecount2;
onecount2=0;
subcat2 = new Array();
<%
int m=0;
Datastore smallclass=(Datastore)request.getAttribute( "dssmall ");
for(int i=1;i <=smallclass.rowCount();i++){

String smallclassid=General.convertNullToHTMLEmpty(smallclass.getItemString(i, "str_smallclassid "));
String bigcalssid=General.convertNullToHTMLEmpty(smallclass.getItemString(i, "str_bigclassid "));
String smallclassname=General.convertNullToHTMLEmpty(smallclass.getItemString(i, "smallclassname "));
%>

subcat2[ <%=m%> ] = new Array( " <%=smallclassname%> ", " <%=bigcalssid%> ", " <%=smallclassid%> ");//产生数组
<%
m++;
}