1

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 ?

Thanks

2

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.setValue(sessionStorage.getItem('key-of-checkbox'));
    checkbox.observe('change', function() {
        sessionStorage.setItem('key-of-checkbox', $F(checkbox));
    });
});
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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