JS判断DropDownList 为空

rczjp 2009-04-03 11:44:32
<asp:DropDownList ID="Forum" runat="server">
<asp:ListItem Text="请选择..." Value=""></asp:ListItem>
<asp:ListItem Text="1..." Value="1"></asp:ListItem>
</asp:DropDownList>
...全文
293 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2009-04-03
  • 打赏
  • 举报
回复
var DDL=document.getElementById("DropDownList1");
var index=DDL.selectedIndex;
var Text=DDL.options[index].text;
var Value=DDL.options[index].value;

document.getElementById("DropDownList1").options[document.getElementById("DropDownList1").selectedIndex].text
llsen 2009-04-03
  • 打赏
  • 举报
回复
if (document.getElementById('<%=Forum.ClientID%>').selectedIndex == 0) 
alert('空')
rczjp 2009-04-03
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 szx1999 的回复:]
写错了。。

JScript codeif (document.getElementById('<%=Forum.ClientID%>').selectedValue == '')
alert('空')
[/Quote]
在JS里面有这种写法吗?
等不到来世 2009-04-03
  • 打赏
  • 举报
回复
写错了。。
if (document.getElementById('<%=Forum.ClientID%>').selectedValue == '') 
alert('空')
等不到来世 2009-04-03
  • 打赏
  • 举报
回复
if (document.getElementById('<%=Forum.ClientID'%>').selectedValue == '')
alert('空')
rczjp 2009-04-03
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 szx1999 的回复:]
JScript codeif (document.getElementById('Forum').selectedValue == '')
alert('空')
[/Quote]试了不行
等不到来世 2009-04-03
  • 打赏
  • 举报
回复
if (document.getElementById('Forum').selectedValue == '')
alert('空')
fenglm999 2009-04-03
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 szx1999 的回复:]
写错了。。

JScript codeif (document.getElementById('<%=Forum.ClientID%>').selectedValue == '')
alert('空')
[/Quote]
支持,js是使用客户端的id,这个'<%=Forum.ClientID%>'是可以取到的
Myth_NiuNiu 2009-04-03
  • 打赏
  • 举报
回复
学习

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧