当前位置: 代码迷 >> ASP >> 在javascript方法中怎么取得页面中DropDownList选中的值?
  详细解决方案

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

热度:81   发布时间:2012-04-23 13:17:38.0
在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;
试试
  相关解决方案