Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:43:41+00:00 2026-06-09T00:43:41+00:00

I am developing a form using Javascript for styling that will be used to

  • 0

I am developing a form using Javascript for styling that will be used to submit many different things. However, the majority of the time the different things will only be slightly different so it would really benefit users if when you press the Back button on the browser, the form is exactly as you left it before you submitted the form.

Note: This already works when using a normal HTML/Javascript-less form, the question I am asking is how I can retain this functionality when using Javascript to hide/replace input fields etc.

I’ve tried History.js and HTML5’s replaceState() but nothing seems to work. Also if it helps, this will be a private website that requires the latest browser installed so don’t feel hesitant to recommend solutions only available in the latest browser releases.

Many thanks!

Update #1: Here’s an image better explaining what I need.

image

Update #2: Okay I managed to crack it perfectly, cross-browser included. I’ll post a solution tomorrow after I’ve had some sleep.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:43:42+00:00Added an answer on June 9, 2026 at 12:43 am

    Okay so I went back to the drawing board and tried to figure something out using the tools I already know exist. The case with each browser (usually, haven’t tested any non-major browsers) is that when you press the Back button after submitting a form, text input fields are usually populated. I wanted to see if this worked the same with hidden input fields, turns out it does!

    So next I set up some Javascript events to listen out for the page load.

    if($.browser.mozilla)
    {
        $(window).on('pageshow', pageManager.init);
    }
    else
    {
        $(pageManager.init);
    }
    

    This works for Chrome, Firefox and IE9. I haven’t tested any other browsers but these are the only browsers that will be used for my private site so it’s good enough for me. I’m sure you can set up your own preferred solution for your needs but this is what worked best for me.

    Anyway the above code means every time the page loads, pageManager.init() will run. Here’s an excerpt of the code I use to check if the Back button was pressed and it’s not simply just a page refresh or a first-time visit:

    if($('input[name="form_submitted"]').val() != '')
    {
        // back button was pressed
    }
    

    As you can see, it’s as simple as checking if your hidden form field contains a value. To actually guarantee a value will be set, make sure to set on submission of your form:

    $('#my-form').submit(function()
    {
        $('input[name="form_submitted"]').val('true');
    }
    

    It really is as simple as that. This is one of the best methods I can think of for determining if the Back button of a browser was pressed. Now, to cache all the form values for the visible fields it can be as simple as using JSON.stringify() on the fields and sticking it all in one hidden field which you decode later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing UI form that has infragistics grid. Users can delete, submit some
I am developing an autocomplete form using JQuery and Rails. However I don't know
i am developing register form using php where i need to upload the file
I am developing a web form using Visual Web Developer Currently I have class
I'm developing a form, and using jQuery UI Autocomplete. When the user selects an
I'm developing a xpage application using an anonymous form for yet unknown (not authenticated)
Using C# I am developing an Excel add-in. This add-in opens a Windows Form
I'm developing a site using the CakePHP framework. I have a form which shows
I am developing an app using Codeigniter. In this app I got a form
I'm developing an blog using ASP.NET , and I want that the user can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.