Reputation: 215
I want to pass form value from one html page to another html page.
I wonder Is that possible to pass values between html page not using server side code.
And if not, how can i pass values? (I prefer to not use server side...)
Here is some my project code :
First HTML page
<form id="myForm" method="post" action="secondHTMLPage URL">
<input type="hidden" id="UserID" name="UserID" value="12345">
</form>
<script type="text/javascript">
$("#myForm").submit();
</script>
Second HTML page
<script type="text/javascript">
// In here, I want to retrieve my $("#myForm")'s data from First Page.
</script>
Upvotes: 1
Views: 2676
Reputation: 68933
You can try with Window.sessionStorage or Window.localStorage.
The read-only
localStorage
property allows you to access a Storage object for the Document's origin; the stored data is saved across browser sessions.
localStorage
is similar tosessionStorage
, except that while data stored inlocalStorage
has no expiration time, data stored insessionStorage
gets cleared when the page session ends — that is, when the page is closed.
Set value in one page
localStorage.setItem('myCat', 'Tom');
//using sessionStorage
//sessionStorage.setItem('myCat', 'Tom');
Get the value in other page
var cat = localStorage.getItem('myCat');
//using sessionStorage
//var cat = sessionStorage.getItem('myCat');
Upvotes: 2