在js中怎么获得ListBox选中的值
解决方案 »
- gridview覆盖了span
- 求助:GridView的数据筛选
- 100分求教把Access导出到Oracle数据库的问题?
- 怎么设置datagrid样式
- 各位大虾:小弟最近遇到了点工程上的难题,不知道那位能帮小弟个忙改一下;把邮箱发给我,我把程序发过去;跪求!!急急急!!!
- ASP 转 ASP.NET 时JAVASCRPIT的使用
- 本菜初学mvc,有个问题想问一下?
- 做了一个搜索的ASCX 用户控件,确报错~~~~~??高手
- 用OWC10的时候为什么会自动增加一个图表呢?(附源码)
- 访问服务器权限出错!
- GridView添加标题行问题 急救助!
- js 无法执行 ajax CalendarExtender 无反映
function Display()
{
var listBox = document.getElementById( "ListBox1 ");
alert(listBox.options[listBox.selectedIndex].value);
document.getElementById( "TextBox1 ").innerText = listBox.options[listBox.selectedIndex].value;
}
</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:ListBox ID= "ListBox1 " runat= "server " onclick = "Display(); ">
<asp:ListItem Selected = "true " Value= "1 " > sfsfsfsf </asp:ListItem>
<asp:ListItem Value= "2 " > s34242 </asp:ListItem>
<asp:ListItem Value= "3 "> sdf2233 </asp:ListItem>
</asp:ListBox>
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox> </div>
</form>
</body>
</html>
http://topic.csdn.net/u/20070605/16/d271b09f-272a-42dd-8c1f-2d089d85aadb.html
for(var i=0;i<list.options.length;i++){
if(list[i].checked){
// 选中
}}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!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> <script src="jquery-1.3.2-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#ListBox1").click(function(){
alert($("#ListBox1").val());
})
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox ID="ListBox1" runat="server">
<asp:ListItem>
1
</asp:ListItem>
<asp:ListItem>
2
</asp:ListItem>
</asp:ListBox>
</div>
</form>
</body>
</html>