I made my very own web page.

How do I have a web page store changes made by javascript?

  • I have a form on a simple web page that has a series of checkboxes. These options represent items that may be retrieved from a database upon clicking the submit button. In addition, there is a place to add an extra option to the page at the bottom. Here is what I am going for: I would like to be able to add the new option using javascript, so that it show up quickly and seamlessly to the user, rather than having to send the request back to the server and add it server-side, then have the user reload the page. However, I also want to make sure that these added fields are preserved so that the next time I load the page, they show up. Unfortunately, my code is proprietary, so I cannot post it here. I hope that people can help me this some ideas without having to actually see the code. Thanks

  • Answer:

    When these checkboxes are added you don't want to go the server but when user presses submit you are anyways going to server, so at that time you can persist this information about new checkboxes on server. Another option is to call to server asynchronously using AJAX to update the server about the state change.

ewok at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

If you still want to store the changes server-side, you can do so quietly in the background. Just use https://developer.mozilla.org/en/XMLHttpRequest, together with a PHP script.

Dennis

You can use the http://coding.smashingmagazine.com/2010/10/11/local-storage-and-how-to-use-it/ to store your changes. localStorage.setItem('favoriteflavor','vanilla');

Michael

If you want session related information to pass thru multiple requests, you can either put the data in a cookie, or with php you can use sessions. http://php.net/manual/en/features.sessions.php

Patrick

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.