需要做到点击一个select 会有2个平级的selelt同时变化这个二级联动该怎么写?asp里

解决方案 »

  1.   

    原理相同的,只是加载两个数据源?给两个select赋值。这个用js处理,和asp,没有关系。数据源的提供可能需要动态的页面提供
      

  2.   

    这里有一个select的联动
    参考一下
      

  3.   

    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>