如何在.aspx页中获取DropDownList的.SelectedIndex [英] How to get .SelectedIndex of DropDownList in .aspx Page

查看:74
本文介绍了如何在.aspx页中获取DropDownList的.SelectedIndex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!
我想在.aspx页面中获取DropDownList的.SelectedIndex.
我将像下面这样使用,但无法正常工作.

Hi !
I want to get .SelectedIndex of DropDownList in .aspx Page.
I will use like below but not working.

if(document.getElementById("<%=ddldocInge.ClientID%>").value==-1)
        {
          alert("Select the Doctor");
          document.getElementById("<%=ddldocInge.ClientID%>").focus();
          return false;
        }

推荐答案

您需要在脚本中执行类似ddldocInge.SelectedIndex的操作.
You need to do something like ddldocInge.SelectedIndex in your script.


代替.value使用.selectedIndex.
Instead .value use .selectedIndex.
if(document.getElementById("<%=ddldocInge.ClientID%>").selectedIndex == -1)
        {
          alert("Select the Doctor");
          document.getElementById("<%=ddldocInge.ClientID%>").focus();
          return false;
        }


这篇关于如何在.aspx页中获取DropDownList的.SelectedIndex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆