Checkbox value after refresh
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 开发者_Python百科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.
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?
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.
精彩评论