一个的特殊的二级联动问题

沧海小鱼 2010-03-16 09:35:56
需要做到点击一个select 会有2个平级的selelt同时变化

这个二级联动该怎么写?

asp里
...全文
191 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
shan1119 2010-03-16
  • 打赏
  • 举报
回复
demo:

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
window.onload=function(){
var s1=document.getElementById("s1");
var s2=document.getElementById("s2");
var s3=document.getElementById("s3");

s1.onchange=function(){resetOption(s1,s2,s3);};
s2.onchange=function(){resetOption(s2,s1,s3);};
s3.onchange=function(){resetOption(s3,s1,s2);};
s1.onclick=function(){bo=this.options[this.selectedIndex];};
s2.onclick=function(){bo=this.options[this.selectedIndex];};
s3.onclick=function(){
bo=this.options[this.selectedIndex];
};
function resetOption(p1,p2,p3){
var opt=p1.options[p1.options.selectedIndex];
for(var i=0;i<p2.options.length;i++){
if(p2.options[i].value==opt.value)p2.options[i]=null;
}
for(var i=0;i<p3.options.length;i++){
if(p3.options[i].value==opt.value)p3.options[i]=null;
}

sortOption(p2);
sortOption(p3);
}
function sortOption(p){
var index=p.options.length;
var flg=true;
for(var i=p.options.length-1;i>=0;i--){
if(p.options[i].value>bo.value)index=i;
if(p.options[i].value==bo.value)flg=false;
}
if(flg){
p.options[p.options.length]=new Option(bo.text,bo.value);
p.insertBefore(p.options[p.options.length-1],p.options[index]);
}
}
};
</script>
<select id="s1">
<option value=0>0</option>
<option value=3>3</option>
<option value=4>4</option>
</select>
<select id="s2">
<option value=1>1</option>
<option value=3>3</option>
<option value=4>4</option>
</select>
<select id="s3">
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
</select>
沧海小鱼 2010-03-16
  • 打赏
  • 举报
回复
这个二级联动要应用在一个循环中

本身的二级联动又是动态

怎么写? 怎么导入变量使得联动的数组变

js不会
cloudgamer 2010-03-16
  • 打赏
  • 举报
回复
这里有一个select的联动
参考一下
Ny-6000 2010-03-16
  • 打赏
  • 举报
回复
上面说提有理。


up
anjing5566 2010-03-16
  • 打赏
  • 举报
回复
原理相同的,只是加载两个数据源?给两个select赋值。这个用js处理,和asp,没有关系。数据源的提供可能需要动态的页面提供
SIOSXIAOQIANG 2010-03-16
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 shan1119 的回复:]
demo:

HTML code

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
window.onload=function(){
var s1=document.getElementById("s1");
var s2……
[/Quote]
完全正确啊。每天回帖即可获得10分可用分

87,924

社区成员

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

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