【发布时间】:2012-11-15 22:09:58
【问题描述】:
如果有人可以帮助我找到解决一个问题的方法,我将不胜感激,可能我需要非常简单的东西,但我不知道如何将它放在一起,所以我需要 - 包含勾选框的部分,然后按钮提交,但如果你不勾选复选框并按下按钮出现窗口,上面写着你必须做......,
我已经完成了,但我需要这个
但是,如果您勾选并按下按钮,应该会顺利出现仅包含文本信息的弹出窗口!我不知道如何得到它, 这是带有复选框和按钮的部分
<form name="form" method="post" action="#" onSubmit="return checkme();">
<input type="checkbox" name="agree" value="agree_terms" class="terms">
I´ve read terms and conditions and I´m ready to shop
<input type="submit" name="submit" value="" class="submit">
</form>
这是javascript
function checkme() {
missinginfo = "";
if (!document.form.agree.checked) {
missinginfo += "You must agree to the Terms and Conditions";
}
if (missinginfo != "") {
missinginfo ="" +
"\n" +
missinginfo + "" +
"\n Please tick the box and try again.";
alert(missinginfo);
return false;
}
else {
return true;
}
}
我尝试了不同的方式
<body>
<title>LIGHTBOX EXAMPLE</title>
<style>
.black_overlay{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
.white_content {
display: none;
position: absolute;
top: 25%;
left: 25%;
width: 50%;
height: 50%;
padding: 16px;
border: 16px solid orange;
background-color: white;
z-index:1002;
overflow: auto;
}
</style>
</head>
<body>
<p>This is the main content. To display a lightbox click <a href = "javascript:void(0)"
onclick = "document.getElementById('light').style.display='block'; document.getElementById('fade').style.display='block'">here</a></p>
<div id="light" class="white_content">This is the lightbox content. <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none'; document.getElementById('fade').style.display='none'">Close</a></div>
<div id="fade" class="black_overlay"></div>
</body>
</html>
但是当我勾选背景上的复选框时,会出现带有内容的窗口,但我需要只有在我勾选复选框并按下按钮后才会出现弹出窗口
【问题讨论】:
-
虽然我明白你想要什么。你在这里没有给我们太多。您至少可以向我们展示您现在拥有的 HTML 代码吗?
-
missinginfo += "You must agree to the Terms and Conditions";仅用于触发发送(如果存在)。missinginfo =""应该是missinginfo +=""吗?无论哪种方式,它都是多余的。我不知道你有两个 if 语句什么时候可以做。你有更多的代码吗?!=也应该是 `!=='
标签: javascript html checkbox popupwindow