Question

I have a piece of code that appends fields to a form as demonstrated in the following jsFiddle.

Is there a way to retain the appended fields after form submission, when a user comes back to the page? I am not asking for code, I am asking if it is possible, and in theory how?

UPDATE:

The data that was in the appended fields is saved to a database, would I then run an if statement to check if there is data for that user then call the append function to create the fields again? Or would it be better to pre-create hidden fields and then just clone, change the type and fill them with data?

Was it helpful?

Solution

Since you already saved all the needed data to your database, i would create the form without the hidden fields. Then when the user clicks a button/link to add additional fields you could send an ajax request fetching the correct data for the additional fields. when the ajax request returns some json/xml/... you can just add the fetched data to your form.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top