62,251
社区成员
发帖
与我相关
我的任务
分享
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript">
function check()
{
var chkObject = document.getElementById('<%=CheckBoxList1.ClientID%>');
var chkInput =chkObject.getElementsByTagName("TABLE");
for(var i=0;i<chkInput.length;i++)
{
if(chkInput[i].checked)
{
alert(chkInput[i].text);
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem Value="1">男</asp:ListItem>
<asp:ListItem Value="2">女</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></div>
<asp:Button ID="Button1" runat="server" OnClientClick="javasrcipt:check()" Text="Button" />
</form>
</body>
</html>
function GetText(strCommon)
{
var inputs = document.all.tags("INPUT");
for (var i = 0; i < inputs.length; i++) // 遍历页面上所有的 input
{
if (inputs[i].type == "checkbox" )
{
Alert(inputs[i].innerText); // inputs[i].innerText就是你想要的Text
}
}
}