求一个2级联动菜单的脚本 jsp页面的2级联动菜单,内容是从后台数据库里查出来的。想要用脚本来实现菜单的联动,希望大家能给个简单实用的脚本外加说明!!!谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script type="text/javascript" language="javascript"> var subindusid=new Array("" <logic:present name="subindus"> //subindus是个list的第二级数据 <logic:iterate id="sindus" name="subindus"> ,"<bean:write name="sindus" property="industryId"/>" // id </logic:iterate> </logic:present> ); var subindusna=new Array("" <logic:present name="subindus"> <logic:iterate id="sindus" name="subindus"> ,"<bean:write name="sindus" property="industryName"/>" // name </logic:iterate> </logic:present> ); function onsel(){ var mainid=""+myform.mainindustry.value; var psel=myform.subindustry.options; for(i=psel.length-1;i>0;i--){ myform.subindustry.remove(i); } if(mainid=='0') return; for(j=1;j<subindusid.length;j++){ var tl=subindusid[j].length-2; var tst=subindusid[j].substring(0,tl); if(tst==mainid){ opt=document.createElement ("OPTION"); opt.value=subindusid[j]; opt.text=subindusna[j]; myform.subindustry.add(opt); } } } </script> <tr> <td> 主行业: </td> <td> <select name="mainindustry" onchange="onsel();"> <option value="0" selected><bean:message key="mainindustry.default"/></option> <logic:present name="allmainindus"> <logic:iterate id="indus" name="allmainindus"> <option value="<bean:write name="indus" property="industryId"/>"><bean:write name="indus" property="industryName"/></option> </logic:iterate> </logic:present> </select> </td> </tr> <tr> <td> 二级行业 </td> <td> <select name="subindustry"> <option value="0" selected><bean:message key="subindustry.default"/></option> </select> </td> </tr> 用了struts的标签 不知道你会不会 我正是用的struts的标签。有些地方不太理解,能把你QQ给我吗? <script type="text/javascript" language="javascript"> var id=new Array("" <logic:notEmpty name="type"> //type是个list的第二级数据 <logic:iterate id="ty" name="type"> ,"<bean:write name="ty" property="personaltypeCategoryId"/>" // id </logic:iterate> </logic:notEmpty> ); var title=new Array("" <logic:notEmpty name="type"> <logic:iterate id="ty" name="type"> ,"<bean:write name="ty" property="personaltypeTitle"/>" // title </logic:iterate> </logic:notEmpty> ); function onsel(){ var mainid=""+myform.category.value; var psel=myform.type.options; for(i=psel.length-1;i>0;i--){ myform.type.remove(i); } if(mainid=='0') return; for(j=1;j<id.length;j++){ var tl=id[j].length-2; var tst=id[j].substring(0,tl); if(tst==mainid){ opt=document.createElement ("option"); opt.value=id[j]; opt.text=title[j]; myform.type.add(opt); } } } </script></head><body> <form method="POST" name="myform"> <table> <tr> <td> 主行业: </td> <td> <select name="category" onchange="onsel();"> <option value="0" selected> 1111 </option> <logic:notEmpty name="category"> <logic:iterate id="ca" name="category"> <option value="<bean:write name="ca" property="personalCategoryId"/>"> <bean:write name="ca" property="personalCategoryTitle" /> </option> </logic:iterate> </logic:notEmpty> </select> </td> </tr> <tr> <td> 二级行业 </td> <td> <select name="type"> <option value="0" selected> 2222 </option> </select> </td> </tr> </table> </form></body>不灵啊,那里不对劲呢?? 这里放qq麻烦,你把你的qq或者msn发我邮箱 [email protected] 你们的jdk是什么版本,java 6 update 10以后的哪种比较稳定 动态向jar包中添加文件的问题 图像的像素点RGB提取 算法高手请进...... 问个这样的问题:怎样自动根据条件转向不同的页面。 有关jbuilder、web.xml文件的一个小问题,请教大家。。。。 请推荐JAVA数据库编程的书 求各位大神指条明路 如何在jJBuild6MobileSet2上建一个MIDlet ? 如何从一个.class文件得到它的.java文件? 一道面试题 控制子窗口打开的位置?
var subindusid=new Array(""
<logic:present name="subindus"> //subindus是个list的第二级数据
<logic:iterate id="sindus" name="subindus">
,"<bean:write name="sindus" property="industryId"/>" // id
</logic:iterate>
</logic:present>
);
var subindusna=new Array(""
<logic:present name="subindus">
<logic:iterate id="sindus" name="subindus">
,"<bean:write name="sindus" property="industryName"/>" // name
</logic:iterate>
</logic:present>
);
function onsel(){
var mainid=""+myform.mainindustry.value;
var psel=myform.subindustry.options;
for(i=psel.length-1;i>0;i--){
myform.subindustry.remove(i);
}
if(mainid=='0')
return;
for(j=1;j<subindusid.length;j++){
var tl=subindusid[j].length-2;
var tst=subindusid[j].substring(0,tl);
if(tst==mainid){
opt=document.createElement ("OPTION");
opt.value=subindusid[j];
opt.text=subindusna[j];
myform.subindustry.add(opt); }
}
}
</script> <tr>
<td> 主行业: </td>
<td>
<select name="mainindustry" onchange="onsel();">
<option value="0" selected><bean:message key="mainindustry.default"/></option>
<logic:present name="allmainindus">
<logic:iterate id="indus" name="allmainindus">
<option value="<bean:write name="indus" property="industryId"/>"><bean:write name="indus" property="industryName"/></option>
</logic:iterate>
</logic:present>
</select>
</td>
</tr>
<tr>
<td> 二级行业 </td>
<td>
<select name="subindustry">
<option value="0" selected><bean:message key="subindustry.default"/></option>
</select>
</td>
</tr>
有些地方不太理解,能把你QQ给我吗?
var id=new Array(""
<logic:notEmpty name="type"> //type是个list的第二级数据
<logic:iterate id="ty" name="type">
,"<bean:write name="ty" property="personaltypeCategoryId"/>" // id
</logic:iterate>
</logic:notEmpty>
);
var title=new Array(""
<logic:notEmpty name="type">
<logic:iterate id="ty" name="type">
,"<bean:write name="ty" property="personaltypeTitle"/>" // title
</logic:iterate>
</logic:notEmpty>
);
function onsel(){
var mainid=""+myform.category.value;
var psel=myform.type.options;
for(i=psel.length-1;i>0;i--){
myform.type.remove(i);
}
if(mainid=='0')
return;
for(j=1;j<id.length;j++){
var tl=id[j].length-2;
var tst=id[j].substring(0,tl);
if(tst==mainid){
opt=document.createElement ("option");
opt.value=id[j];
opt.text=title[j];
myform.type.add(opt); }
}
}
</script>
</head><body>
<form method="POST" name="myform">
<table>
<tr>
<td>
主行业:
</td>
<td>
<select name="category" onchange="onsel();">
<option value="0" selected>
1111
</option>
<logic:notEmpty name="category">
<logic:iterate id="ca" name="category">
<option value="<bean:write name="ca" property="personalCategoryId"/>">
<bean:write name="ca" property="personalCategoryTitle" />
</option>
</logic:iterate>
</logic:notEmpty>
</select>
</td>
</tr>
<tr>
<td>
二级行业
</td>
<td>
<select name="type">
<option value="0" selected>
2222
</option>
</select>
</td>
</tr>
</table>
</form>
</body>不灵啊,那里不对劲呢??