无论我是否选择复选框,它仍然会给出 MsgBox...
我下面的代码将在这两种情况下重定向到 Google:如果用户选择该复选框,那么它将重定向到 www.google.com,但如果用户忘记选中该复选框,则会显示带有以下内容的消息框:OK按钮。当我点击“确定”时,它应该重定向到 www.google.com
I want
当用户忘记选中任何复选框以显示带有以下内容的 MsgBox 时OK按钮并停留在同一页面上。否则,如果用户选择任何复选框,则重定向到 www.google.com。
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:CheckBox ID="CheckBox2" runat="server" />
</div>
<asp:Button ID="Button1" runat="server" OnClientClick ="return ConfirmSelection(this.form);" Text="Button" />
</form>
<script type="text/javascript">
function ConfirmSelection(frm)
{
for (i=0; i<=1; i++) {
//chkSubjectOfInterest is the id of your checkbox control
if (frm.elements[i].name.indexOf('chkSubjectOfInterest') != -1)
{
if (frm.elements[i].checked)
{
return true
}
}
}
alert('You haven\'t selected an item yet!')
return false
}
</script>
</body>
</html>
这一点?
for (i=0; i {
它应该是这样的:
for (i=0; i <= loopnumber; i++)
{
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)