tags:

views:

156

answers:

2

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.

+1  A: 

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.

ItzWarty
Please don't use the PHP approach, by the way, **OR I WILL DESTROY YOU**... its ugly and its a waste of time+cause of stress. Program for the future standard if that standard is coming soon [localStorage is even supported by IE!]
ItzWarty
+1  A: 

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?

Lee