誰かが1つの問題を解決する方法を見つけるのを手伝ってくれたら幸いです。おそらく非常に単純なものが必要ですが、それを1つに入れる方法がわからないので、必要なもの-チェックボックスを含むセクション、次に送信ボタン、しかし、チェックボックスにチェックを入れずにボタンを押すと、You must do....というウィンドウが表示されます。
やったけどこれが欲しい
しかし、チェックを入れてボタンを押すと、テキスト情報だけのポップアップ ウィンドウがスムーズに表示されます。それを取得する方法がわかりません。これは、チェックボックスとボタンのあるセクションです
<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>
しかし、背景のチェックボックスにチェックを入れると、コンテンツを含むウィンドウが表示されますが、ボックスにチェックを入れてボタンを押した後にのみポップアップウィンドウが表示される必要があります