私はチェックボックス付きの画面を持っています。ラベルをクリックすると、テキストと同意ボタンを含む新しいウィンドウが開きます。ユーザが同意ボタンをクリックすると、チェックボックスを参照する一意のIDでクッキーが設定されます。クッキーが1に等しいかどうかに基づいてこのチェックボックスをチェックするにはどうすればよいですか?コードは以下のとおりです。クリックすると、Cookieを設定してチェックボックスをチェックします
document.cookie = "doc_35_readit=0";
$('#have_read_agreement').on('click', function() {
document.cookie = "doc_35_readit=1";
});
ウィンドウが閉じているときに、チェックボックスをチェックする方法がわかりません。このような何か?
if (cookie("doc_35_readit") == "1") {
$(".doc_35_readit").click();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Initial checkbox: -->
<input type="checkbox"
id="agreementChecker-0"
name="agreeCheck-0"
value="35"
class="mandatory agreeChecker doc_35_readit"/>
<!-- New Window opens with text, button at bottom: -->
<p align="center" id="have_read_agreement" style="text-align:center;font-size:20px;">
<a href="javascript:window.close()" class="btn-read">I have read this agreement and accept all terms and conditions.</a>
</p>