首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-01-01 
js获取页面控件值的问题请问用js获取 asp:DropDownList IDDropDownList1 runatserver Width155px

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);

热点排行