How to have form values same on back button click in IE

How to have form values same on back button click in IE?

When I click on back button with following

<input type="button" value="Back" onClick="history.go(-1);return true;" class="back-button">

It does not show form values in IE.

i have a form with some input when i submit form go to next page there i have one back button when click on that i go on form page but there is no values on form which i have field this is issue with IE



Form values are not usually saved when moving between pages. They could be if your server configuration supports page caching. An alternative however is to save the form values into cookies or the newer html 5 session storage. This can be accomplished by firing a function in the form header known as onsubmit.


<form id="[form id]" name="[form name]" action="[some action]" method="[GET or POST]" onsubmit="saveFormValues();">

In this case when the user clicks the submit button to continue, the values are saved into local browser storage (in essence a local cache).

When the back button is clicked, the onload event of the page could check for the values and then re-assign them to the appropriate fields, thus retaining the choices, selections, and input the user previously entered.

To set a HTML 5 session storage variable:

    sessionStorage.[Variable Name]=$([Field Name]).val();

On return to the page:

if(typeof(sessionStorage)!=="undefined") {
    $([Field Name]).val(sessionStorage.[Variable Name]);

This last block will retrieve the saved state value. After final submission is complete, make sure you call:


This clears the session storage variables and will make the form appear as a new form when the user revisits the page.

Hope this helps.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.