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

在javascript方法中怎么取得页面中DropDownList选中的值?

2012-04-23 
在javascript方法中如何取得页面中DropDownList选中的值???protected void Page_Load(object sender, Even

在javascript方法中如何取得页面中DropDownList选中的值???
protected void Page_Load(object sender, EventArgs e)
  {
  if (!IsPostBack)
  {
  this.DropDownList1.DataSource = new PartManager().GetAll();
  this.DropDownList1.DataTextField = "PartName";
  this.DropDownList1.DataValueField = "Id";
  this.DropDownList1.DataBind();
   
  }
  }

页面中绑定DropDownList。

<script language="javascript" type="text/javascript" >
  function mytest2() {
  var part = null;
  var dropdownlist = document.getElementById("DropDownList1");
</script>
想取得选中项的DataValueField接着怎么写???

[解决办法]
dropdownlist.options[dropdownlist.selectedIndex].value;
试试

热点排行