怎么获取DropDownList里面的值呀!

DuanChaCha 2012-03-14 01:44:48
<script type="text/javascript">
function SlectInfo()
{
点击查询按钮时,怎么获取 DropDownList 控件里面选择的值呀!请各位大侠帮忙指点下,小弟万分感谢!
}
</script>
<div>
<asp:DropDownList ID="dropdownlist1" runat="server">
<asp:ListItem Value="学习管理">学习管理</asp:ListItem>
<asp:ListItem Value="学习方法">学习方法</asp:ListItem>
<asp:ListItem Value="学习目标">学习目标</asp:ListItem>
</asp:DropDownList>
</div>

<div>
<a class="button" id="select" onclick="SlectInfo()" title="新增" runat="server>
<span>查询</span>
</a>
</div>
...全文
1836 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
EnForGrass 2012-03-14
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 porschev 的回复:]
HTML code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_20120301_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/……
[/Quote]
我只是觉得你该结贴了
Happy_IT_Yatou 2012-03-14
  • 打赏
  • 举报
回复
都有这么给力呢!!!
麦麦_同学 2012-03-14
  • 打赏
  • 举报
回复
onchange 触发选择里面的
a279417687 2012-03-14
  • 打赏
  • 举报
回复
后台获取显示值:dropdownlist1.selectItems.text
后台获取ID值:dropdownlist1.selectItems.value

前台jquery获取$("#dropdownlist1").val();
qingwa_ifeng 2012-03-14
  • 打赏
  • 举报
回复
后台获取显示值:dropdownlist.selectItems.text
后台获取ID值:dropdownlist.selectItems.value
bu在服务区 2012-03-14
  • 打赏
  • 举报
回复
dropdownlist1.SelectedValue;
bu在服务区 2012-03-14
  • 打赏
  • 举报
回复
后台获取的方法 dropdownlist1..SelectedValue;
porschev 2012-03-14
  • 打赏
  • 举报
回复


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_20120301_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">

<script type="text/javascript">
function SlectInfo()
{
var ddl = document.getElementById("<%=dropdownlist1.ClientID %>");
var ddlVal = ddl.options[ddl.selectedIndex].value;

alert(ddlVal);
}
</script>

<div>
<asp:DropDownList ID="dropdownlist1" runat="server">
<asp:ListItem Value="学习管理">学习管理</asp:ListItem>
<asp:ListItem Value="学习方法">学习方法</asp:ListItem>
<asp:ListItem Value="学习目标">学习目标</asp:ListItem>
</asp:DropDownList>
</div>
<div>
<a class="button" id="select" onclick="SlectInfo()" title="新增" runat="server"><span>
查询</span> </a>
</div>
</form>
</body>
</html>


bdmh 2012-03-14
  • 打赏
  • 举报
回复


var s = $("#dropdownlist1").val();
document.write(s);
bdmh 2012-03-14
  • 打赏
  • 举报
回复

var s = document.getElementById("dropdownlist1").options[window.document.getElementById("DropDownList1").selectedIndex].text;
document.write(s);
半瓶神仙水 2012-03-14
  • 打赏
  • 举报
回复
例:$("#ddlShopType").val() --Jquery方式

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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