62,046
社区成员
发帖
与我相关
我的任务
分享
var inputs = document.getElementsByTagName("input");
for(var i = 0; i < inputs.length; i++)
{
if(inputs[i].type == "checkbox" && inputs[i].check){
alert(inputs[i].value)//inputs[i].value就是需要的值
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="CSDNTEST.WebForm4" %>
<!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 type="text/javascript" language="javascript">
function IsCheck() {
var checkid = document.getElementById("<%= CheckBox1.ClientID %>");
if (checkid.checked == false) {
alert("Please check it.!~");
}
else {
alert("Already Check it.!~");
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox1" runat="server" Text="选择" />
<asp:Button ID="Button1" runat="server" Text="Check the checkbox" OnClientClick="IsCheck();" />
</div>
</form>
</body>
</html>
<script type="text/javascript" language="javascript">
function IsCheck() {
var checkid = document.getElementById("<%= CheckBox1.ClientID %>");
if (checkid.checked == false) {
alert("Please check it.!~");
}
else {
alert("Already Check it.!~");
}
}
</script>