当前位置: 代码迷 >> ASP.NET >> js获取页面控件值的有关问题
  详细解决方案

js获取页面控件值的有关问题

热度:6071   发布时间:2013-02-25 00:00:00.0
js获取页面控件值的问题
请问用js获取 <asp:DropDownList ID="DropDownList1" runat="server" Width="155px">
  <asp:ListItem>a</asp:ListItem>
  <asp:ListItem>b</asp:ListItem>
  <asp:ListItem>c</asp:ListItem>
  </asp:DropDownList>
这个控件的选中的值怎么做.如果这样:document.getElementById("DropDownList1").value获取不到,document.getElementById("DropDownList1").innerText却返回三个值.我只想取得选中的值应怎么做?

------解决方案--------------------------------------------------------
document.getElementById("DropDownList1").selectvalue吧
------解决方案--------------------------------------------------------
var select = document.getElementById("DropDownList1");
window.alert(select.options[select.selectedIndex].value);
  相关解决方案