Jump to content

Repopulating Form on Reload


HawkDev
 Share

Recommended Posts

I have an online form, which has various dropdown lists. One of these is for names of clients, one is for the location, one is for time of appointment, etc. It also has a function to add items onto the dropdown lists if it is a new client. This means that the page has to be reloaded to repopulate the dropdown list with the new client name.

However, there are a lot of different dropdown lists on the form, and if the page is reloaded, I want the particular selections that the user has already made to be reloaded when the page is reloaded, so that they do not have to start again just because one dropdown list needed to be edited.

Can you please explain how to do this? Thank you.

Link to comment
Share on other sites

Do you want to do all of that in Javascript?  If so, put a handler on each dropdown that runs when the value is changed, and save the new value.  When the page is loaded check for that saved data and set the values of each field.

Link to comment
Share on other sites

  • 2 weeks later...

Thank you. I understand that I can use an event handler like ‘onchange’. That is not difficult. However, what I am struggling with is how to save the data between the change of choice in the drop down menu, and the reload of the page. 

Link to comment
Share on other sites

I tried using local storage, but I can’t seem to get the system to store the data, and then recall it on reload. Can you please give me a clear example of how this would work for multiple variables?

Link to comment
Share on other sites

localStorage is just like sessionStorage, but sessionStorage only lasts while they're on your site, it won't be there if they come back.  localStorage will.  It's exactly the same to use it though, the difference is persistence.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...