Jump to content

Repopulating Form on Reload


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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...