easu ui 下拉框选择某项时打开对应的网页 onSelect() window.onen()

来源:互联网 发布:js封装对象 编辑:程序博客网 时间:2024/06/11 05:23

页面代码

   <select id="material2" name="material2" class="easyui-combobox"                
                        style="width:153px">
                        <option value="0">普通物料</option>   
                        <option value="1" selected>电力电缆</option>   
                        <option value="2">光缆</option>
                    </select></td>

效果


后台JS

$("#material2").combobox({
        onSelect:function(option){
            var v = $('#material2').combobox('getValue');
            if(v == 0){
                window.open('platform/inventory/thresholdList.jsp','_self');
            }else if(v == 1){
                window.open('platform/inventory/thresholdCableList.jsp','_self');
            }else if(v == 2){
                 window.open('platform/inventory/thresholdOpticalCableList.jsp','_self');
            }
        }
    });

下拉框 id :material2 ,对应的选择事件代码:

$("#material2").combobox({
        onSelect:function(option){
            var v = $('#material2').combobox('getValue');
          alert(  "__________"+v);          //打印出选择的值的option值

        }
    });

然后根据选择的值打开对应的页面(切换页面)

if(v == 0){
                window.open('platform/inventory/thresholdList.jsp','_self');
            }else if(v == 1){
                window.open('platform/inventory/thresholdCableList.jsp','_self');
            }else if(v == 2){
                 window.open('platform/inventory/thresholdOpticalCableList.jsp','_self');
            }



以前是碰到问题解决就过去了,从来不记,第二次碰到就考脑袋,现在感觉记忆力下降了,所以记下来,还能帮到遇到相同问题的朋友。

1 0