问题描述
想实现,选定下拉框1大类后,下拉框2筛选出对就大类的小类,目前是用<selectname="zcdl"onchange="selectsteelkind()"><optionvalue="00"selected>请选择大类</option>中的onchage实现functionselectsteelkind(){document.form1.action="aa.jsp?index=3";document.form1.submit();}其中aa.jsp是本页面,但aa.jsp还有其它项,下拉框功能实现后其它的项也跟着刷新了,录入的其它项就没有了,如何改成只提交下拉框项其它项不动。
解决方案
解决方案二:
用到级联一个小例子<HTML><HEAD><METAhttp-equiv="Content-Type"content="text/html;charset=gb2312"><TITLE>级联显示</TITLE><SCRIPTtype="text/javascript">functionshowType(party){vararttype=newArray();arttype[0]=["人类","暗夜精灵","矮人","侏儒"];arttype[1]=["兽人","牛头人","亡灵","巨魔"];if(party!=0){document.myform.artTarget.options.length=0;for(variinarttype[party-1]){document.myform.artTarget.options.add(newOption(arttype[party-1][i],parseInt(i)+1))}document.myform.artTarget.options.selectedIndex=0;showPic(1)}}functionshowPic(num){vartype=document.myform.artParty.value;if(type==1){for(vari=1;i<5;i++){if(num==i){document.getElementById("lm"+i).style.display="block";}else{document.getElementById("lm"+i).style.display="none";}document.getElementById("bl"+i).style.display="none";}}elseif(type==2){for(vari=1;i<5;i++){if(num==i){document.getElementById("bl"+i).style.display="block";}else{document.getElementById("bl"+i).style.display="none";}document.getElementById("lm"+i).style.display="none";}}}</SCRIPT><STYLEtype="text/css">td{font-size:14px;font-family:"宋体";font-weight:bold}</STYLE></HEAD><BODY><FORMaction=""method="post"name="myform"><TABLEwidth="666"cellpadding="0"cellspacing="0"background="images/bg.jpg"align="center"><TR><TDheight="70"align="center"><H3>魔兽世界八大种族(图)</H3></TD></TR><TR><TDalign="center">阵营选择<SELECTname="artParty"onChange="showType(this.selectedIndex)"style="width:140px"><OPTIONvalue="">--请选择你的阵营--</OPTION><OPTIONvalue="1">联盟</OPTION><OPTIONvalue="2">部落</OPTION></SELECT></TD></TR><TR><TDheight="44"align="center">角色选择<SELECTname="artTarget"onChange="showPic(this.value)"style="width:140px"><OPTIONvalue="">--请选择一个种族--</OPTION></SELECT></TD></TR><TR><TDalign="center"height="234"><DIVid="lm1"style="display:none"><IMGsrc="images/humans-small.jpg"></DIV><DIVid="lm4"style="display:none"><IMGsrc="images/gnomes-small.jpg"></DIV><DIVid="lm3"style="display:none"><IMGsrc="images/dwarves-small.jpg"></DIV><DIVid="lm2"style="display:none"><IMGsrc="images/nightelves-small.jpg"></DIV><DIVid="bl1"style="display:none"><IMGsrc="images/orcs-small.jpg"></DIV><DIVid="bl2"style="display:none"><IMGsrc="images/tauren-small.jpg"></DIV><DIVid="bl3"style="display:none"><IMGsrc="images/undead-small.jpg"></DIV><DIVid="bl4"style="display:none"><IMGsrc="images/trolls-small.jpg"></DIV></TD></TR></TABLE></FORM></BODY></HTML>
解决方案三:
我现在下拉框联动是实现了,但因为调用了aa.jsp所以其它录入项值被刷新了,所就这个改动
解决方案四:
用ajax啊,不用提交整个表单
解决方案五:
原代码<tdwidth="77"height="41"align="right"><spanclass="style14">资产名称</span></td><tdwidth="218"align="left"><inputtype="text"name="selzcmc"class="style28"id="selzcmc2"size="28"align="left"/></td><tdheight="39"align="right"class="style14">资产类型</td>//////////////////<tdcolspan="2"><palign="center"><selectname="zcdl"onchange="selectsteelkind(){"><optionvalue="00"selected>请选择大类</option><%Stringid1=request.getParameter("zcdl");if(id1==null){id1="00";}try{con=common.ConnectDataBase.getConnection();stmt=con.createStatement();Stringsql="selectdistinctdlbm,dlmcfromsb_zcdl";//连接一期数据库ResultSetrs=stmt.executeQuery(sql);while(rs.next()){Stringfirstid=rs.getString("dlbm");Stringfirstname=rs.getString("dlmc");%><optionvalue="<%=firstid%>"<%=firstid.equals(id1)?"selected":""%>><%=firstname%></option><%}rs.close();}catch(Exceptione){e.printStackTrace();}finally{try{stmt.close();}catch(Exceptione){e.printStackTrace();}try{con.close();}catch(Exceptione){e.printStackTrace();}}%></select></td><tdcolspan="2"><palign="center"><selectname="zclx"><optionvalue="00"selected>请选择小类</option><%try{con=common.ConnectDataBase.getConnection();stmt=con.createStatement();System.out.println(id1);Stringsql="selectzclxmc,zclxbmfromsb_zclxwherezclxbmlike'"+id1.trim()+"%'";System.out.println(sql);ResultSetrs=stmt.executeQuery(sql);while(rs.next()){thirdid=rs.getString("zclxbm");thirdname=rs.getString("zclxmc");%><optionvalue="<%=thirdid%>"><%=thirdname%></option><%}rs.close();}catch(Exceptione){e.printStackTrace();}finally{try{stmt.close();}catch(Exceptione){e.printStackTrace();}try{con.close();}catch(Exceptione){e.printStackTrace();}}%></select></td>////////////////functionselectsteelkind(){document.form1.action="aa.jsp?index=3";document.form1.submit();}下拉框联动做到了,但先前录入的资产名称项值没了,如何改
解决方案六:
该回复于2011-03-02 13:21:15被版主删除
解决方案七:
ajax无刷新
解决方案八:
必须AJAX啊兄弟