Have an account? Sign in
Login  Register  Facebook
How to retain checkbox value after refresh?
hi guys,

How to retain the checkbox value (in js) after refresh?
There is a checkbox in this form. When the page is refreshed, the checkbox data disappears.
Is there a way to refresh the page, while keeping the checkbox data?

I have a window (#1) with a form and checkbox. #1 has a link to pop up another window (#2) with another form. When the form on #2 is completed, #1 is refreshed.

My project is a combination of PHP and JS..please help

Thank you.
Started: September 16, 2011 Latest Activity: September 16, 2011 checkbox retain
2 Answers
I could be wrong, but possibly the easiest way would be to write the answer to a session variable each time a check box is clicked using $.post or something a long those lines. And you would simply load the results out of the $_SESSION['checkbox'] or other such variable

Does that make sense?

Posted: is_set
In: September 16, 2011

Pretty approach:
If you\'re up with using HTML5, you can set a variable in localStorage every time a textbox is checked... and then load from localStorage on page load... or i guess you can also save your state with the page unload event...

Not-so-pretty approach:
If you want to use PHP, you can use heartbeats to sync with the server every once in a while.

Posted: MacOS
In: September 16, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer