Answer the question
In order to leave comments, you need to log in
How to organize temporary storage for data from several forms?
The essence of the task is this: there are several forms, each has save buttons (let's call them submits). And there is a main submit on the page, by clicking on which the data from all forms is saved to the database. After filling out each form, the user clicks on its submission and the data must be stored somewhere in temporary storage (on the client), so that later, after filling out all the forms, through the main submit, all the data is saved to the database (on the server). How to implement such a perversion?) What is better to use as temporary storage?
Answer the question
In order to leave comments, you need to log in
Yes, in principle, you can create a table in the local database for temporarily filling out forms. Have the user save a cookie, which will be the key in your string. With each submission, the user sends this key and data from one of the forms, the local temporary table is supplemented. When you click a big submit, from the temporary table it already goes to the main one.
Periodically delete old records of the temporary table if they hang there, for example, for more than a day, and then make the cookie become obsolete in a day
If the data needs to be stored until the page is reloaded, just create an object for each form and keep it in memory, updating it if necessary. Any other solution under these conditions is overkill.
Here is the simplest option .
You can store data directly in forms. If you implement a functionality in which, when the first form is "submitted", it is deleted and the second form is loaded - just do not delete the first one, but hide it with css. Aleksey Ukolov
's
version is just as good, but it's more difficult.
If real page reloads or transition to other pages are coming - then use sessionStorage/localStorage
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question