欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

获取DropDownList选择项的值

程序员文章站 2022-04-05 12:39:18
...
 1 <script type="text/javascript" language="javascript"> 
 2           function CheckDropDownList() { 
 3               var dropDownList = document.getElementById("<%=DropDownListID.ClientID %>"); //获取DropDownList控件 
 4               var dropDownListValue = dropDownList.options[dropDownList.selectedIndex].value; //获取选择项的值 
 5               //注:DropDownListID是DropDownList控件的ID。 
 6    
 7               //JS验证是否有非0值: 
 8               if (dropDownListValue == 0) { 
 9                   alert("请选择……."); 
10                  dropDownList.focus(); 
11                  return false; 
12              } 
13              else { 
14                  return true; 
15              } 
16          } 
17      </script>

 

function enble() {
            var ddl = document.getElementById("<%=ddl_YesNo_State.ClientID %>");
            var txt = document.getElementById("<%=btn_SaveALL.ClientID %>");
            var ddlValue = ddl.options[ddl.selectedIndex].value;
            if (ddlValue.toString() == "已发放") {
                txt.disabled = true;
            }
            else {
                txt.disabled = false;
            }
        }

转载于:https://www.cnblogs.com/tangge/archive/2012/05/28/2521515.html