The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Stay in same div when refresh page

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #241163

    When I refresh my page it goes back to the first div and does not stay on the same div

    If I am on join_form_2 and want to refresh page with out it going back to the first join_form_1 how can I make it stay?


    Local Storage and cookies spring to mind.

    If you want to keep all the form data when the page is refreshed, try Googling something like “retain form values in local storage” and start your research there.

    If you simply want to remember a selected tab, a cookie might be enough, so Google how to read and write cookies.

    Ilan Firsov

    If it’s just plain tabs then I would use the hash (#) part of the URL. On tab change update the hash for the tab clicked, and on page load display the correct tab based on the hash. This method also allows your users to link to specific tabs so that’s a plus.

    Depends a bit on how you handle it on the server end, the simple tabs solution can be perfect, or not suitable here at all.
    What I might do in similar situation is post a the form to the server and then change what is returned to the client side to include only the appropriate form parts based on some logic (maybe save the step the user is currently on as a cookie or in the database, or even check what fields are filled and display the correct step based on that)


    Any examples would be use full

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.