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

jsp中怎么 实现两个下拉框 的联动? 不想用Ajax!
jsp中怎么   实现两个下拉框   的联动?

不想用Ajax!因为是少量的用到联动!

------解决方案--------------------
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 typeid=new Array( " "
<logic:notEmpty name= "type ">
<logic:iterate id= "ty " name= "type ">
, " <bean:write name= "ty " property= "personaltypeId "/> " // title
</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.personalCategoryId.value;
var psel=myform.personaltypeId.options;
for(i=psel.length;i> 0;i--){
myform.personaltypeId.remove(i);
}
if(mainid== '0 ')
return;
var sel = document.getElementById( 'personaltypeId ').options;

for(j=1;j <id.length;j++){
if(id[j]==mainid){
var inserto = new Option(typeid[j],title[j]);
sel[sel.length]=new Option(title[j],typeid[j]);
}
}
document.all.personaltypeId.disabled=false;
return true;

}

.....

<select style= "width:150px " name= "personalCategoryId " onchange= "onsel(); ">
<option value= "-1 "> 请选择 </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>

<select style= "width:150px " name= "personaltypeId " disabled>
<option value= "-1 "> 请选择 </option>
<logic:notEmpty name= "type ">
<logic:iterate id= "ty " name= "type ">
<option
value= " <bean:write name= 'ty ' property= 'personaltypeId '/> ">
<bean:write name= "ty " property= "personaltypeTitle " />
</option>
</logic:iterate>
</logic:notEmpty>
</select>

看不懂问我
------解决方案--------------------
那就直接用js算了
function selectCity(v1,v2)
{