zoukankan      html  css  js  c++  java
  • js获取select改变事件

    js获取select改变事件onchage前的值 和 onclick事件

    <select id="wupin_id" name="wupin_id" onclick="saveLast()" onchange="changeForm(this.value)" >
    <option value="0" selected>请选择您要使用的设备类型</option>
    <option value="001">惠普扫描仪G5590</option>
    <option value="002">惠普扫描仪G2410</option>
    <option value="003">惠普扫描仪G3110</option>
    </select>

    <script>
    var lastIndex,lastValue;

    function saveLast(){
    var select = document.getElementById("wupin_id");

    lastIndex = select.selectedIndex;
    var midValue = select.options[lastIndex].value;
    //var text = select.options[index].text;
    if(midValue!="0"){
    lastIndex = select.selectedIndex;
    lastValue = select.options[lastIndex].value;
    }
    }

    应用:
    function changeForm(val){
    var obj=document.getElementById("wupin_id");
    var tr01=document.getElementById("tr01").value;
    var flag=document.getElementById("saverk").disabled;
    var flag2=document.getElementById("tr01").disabled;
    if(val!="0" && flag2==true){
    document.getElementById("tr01").disabled=false;
    document.getElementById("tr01").focus();
    }
    if(val!="0" && tr01!="" && flag!=true){
    alert("请先保存入库,再进行其他型号物品的扫描录入!");
    obj.options[lastIndex].selected=true; //加载用户改变以前的选中的值
    document.getElementById("saverk").focus();
    }

    }

  • 相关阅读:
    149. Max Points on a Line(js)
    148. Sort List(js)
    147. Insertion Sort List(js)
    146. LRU Cache(js)
    145. Binary Tree Postorder Traversal(js)
    144. Binary Tree Preorder Traversal(js)
    143. Reorder List(js)
    142. Linked List Cycle II(js)
    141. Linked List Cycle(js)
    140. Word Break II(js)
  • 原文地址:https://www.cnblogs.com/nianshi/p/1657752.html
Copyright © 2011-2022 走看看