我有一个dropdownlist 我现在想用javascript 判断dropdownlist选项是否选中,这个应该怎么做

解决方案 »

  1.   

    var objselect=ducoment.getElementByid("")
    for()
    {
       if(objselect.options[i].selected="selected")
       ///
    }
      

  2.   

    document.getElementById("控件的ID").value==null
      

  3.   

    document.getElementById("ddl").selectedIndex=="0"
      

  4.   

    IF(document.getElementById(<%=dropdownlist1.ClientID%>).options[0]==true) 表示当前选中的为第一项!
      

  5.   

    document.getElementById("ddl").selectedIndex=="0" 或者
    document.getElementById("ddl").selectedValue==null 应该也可以 单不能用value你试试看吧~
      

  6.   

    alert(document.getElementById("控件的ID").value=="要判断是否选中的项的value值");
      

  7.   

    方面有很多种,看你喜欢那种了,本人随便提供一种在.cs给提交按钮加一个属性Button1.Attributes.Add("onclick", "checkValue()");
        function checkValue()
        {
          if(document.getElementById("DropDownList1").value==0)//这里值的判断根据你的下拉框情况而定,我这里假设没选是为0
          {
          alert("请选择!");
          return false;
          }
          return true;
        }
      

  8.   

    是否选择了“亲爱的”var objselect=ducoment.getElementByid("select1");
    for(i=0; i<objselect.length;i++)
    {
      if(objselect.options[ddlCustodyName.selectedIndex].value=="亲爱的")
      { break; }
    }
      

  9.   

    使用 SelectedIndex 属性确定 DropDownList 控件中的选定项
      

  10.   

    http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.dropdownlist.selectedindex(VS.80).aspx