现在的位置: 首页 > 综合 > 正文

JS获取DropDownList的value值与text值

2017年11月06日 ⁄ 综合 ⁄ 共 575字 ⁄ 字号 评论关闭

  <script type="text/javascript" language="javascript">
    
function SearchChange()
    {
        
var ddl = document.getElementById("DropDownList1")   
        
var index = ddl.selectedIndex;   
            
        
var Value = ddl.options[index].value;   
        
var Text = ddl.options[index].text;
        
        alert(Value);
    }
    
</script>

 

<asp:DropDownList ID="DropDownList1" runat="server" onchange="SearchChange();">
    
<asp:ListItem Value="0">111</asp:ListItem>
    
<asp:ListItem Value="1">222</asp:ListItem>
    
<asp:ListItem Value="2">333</asp:ListItem>
</asp:DropDownList

抱歉!评论已关闭.