I am using prototype in Magento custom module and have a requirement to keep the checkbox selected after page reload if its clicked. The scenarios are as under:

  1. Keep checkbox unchecked when the page loads first time.
  2. If user clicks on checkbox and reload the page, keep the checkbox selected.
  3. If user unchecks and reload the page, keep the checkbox unchecked.

How could I achieve this using prototype ?


1 Answer 1


Without any code samples to start from I'm just guessing at what you mean. Did you try anything yet?

if (window.sessionStorage) document.observe('dom:loaded', function() {
    var checkbox = $('id-of-checkbox');
    checkbox.observe('change', function() {
        sessionStorage.setItem('key-of-checkbox', $F(checkbox));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.