Note that there are some explanatory texts on larger screens.

plurals
  1. POCheckbox must stay checked on all pages
    text
    copied!<p>I have a checkbox for confirming ToS. Befor user doesn't check this checkbox and confirm ToS, the PayPal button is overlayed with 50% transparent layer and can't be pressed. The same thing with another PayPal buttons, View Card etc. If user tries to press any PayPal button without checking the checkbox, he gets JS alert, that he must check it and confirm ToS.</p> <p>My problem is, that the checkbox forgets its checked state, if user reloads the page or goes to another page, so he must check the checkbox on each page, it's sad.</p> <p>Here is the code, HTML and JS, which make checkbox, overlaying and alert pushing. The code works inside of Joomla framework and works with Joomla's components K2 JQuery: HTML</p> <pre><code>&lt;p class="toskorb"&gt;Please check the checkbox and confirm our ToS!&lt;input class="checkbox" name="TOS" id="TOS" value="read" type="Checkbox" /&gt;&lt;img src="https://www.paypalobjects.com/de_DE/DE/i/btn/btn_paynowCC_LG.gif"&gt; </code></pre> <p></p></p> <p>JS</p> <pre><code>var $K2 = jQuery.noConflict(); $K2(document).ready(function(){ //$K2('#TOS').attr('checked', false); //$K2('input[type=image]').attr("class", "agbunchecked"); //$K2('input[type=image]').bind("click", giveAllert); if(!$K2('#TOS').attr('checked')) // { $K2('input[type=image]').attr("class", "agbunchecked"); $K2('input[type=image]').bind("click", giveAllert); } function giveAllert() { alert("Please check the checkbox and confirm our ToS!"); return false; } $K2('#TOS').change(function(event){ if(this.checked) { $K2('input[type=image]').attr("class", "agbchecked"); $K2('input[type=image]').unbind("click"); } else { $K2('input[type=image]').attr("class", "agbunchecked"); $K2('input[type=image]').bind("click", giveAllert) } }); }); </code></pre> <p>It would be great, if somebody knowing the stuff can complete this code for staying checkbox once checked be checked on all pages. thank you for any code snippet, completion and advice in right direction</p> <p>PS: Sorry i said it not earlier: i'm looking for a solution with session rather than cookie, if possible. After last eu cookie law more and more people reject cookies:(</p> <p>PPS: This code does the remembering of checkbox checked status at page refreshing and back&lt;->forward browsing:</p> <pre><code>&lt;?php $a = array("ToS_yes"); foreach($a as $key =&gt; $value) { echo "&lt;input type='checkbox' name='rating[]' value='$value'"; if(in_array($value,$_POST['rating'])) echo " checked "; echo "&gt;$value"; } </code></pre> <p>?> But how to remember the status on another pages too? Thats the trick</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload