Reputation: 65
I'm looking for a way to have users fill out a form and then print their information through the entire site (Like when you sign in to StackOverflow, your name changes on the top and it retains the information as you navigate the rest of the site). I'm thinking it's something to do with placing "onClick" on the submit button, but I need the information to be carried throughout the pages.
<form name="input" action="html_form_action.asp" method="get">
First name: <input type="text" name="FirstName" value="Mickey" /><br />
Last name: <input type="text" name="LastName" value="Mouse" /><br />
<input type="submit" value="Submit" />
</form>
Thanks in advance.
Upvotes: 0
Views: 177
Reputation: 328614
If it's just a little bit of information, use a cookie.
If it's more information and you only need to support HTML(5) capable browsers, you can also use local storage which is basically a map of key-value-pairs which the browsers save in a safe place.
Upvotes: 1
Reputation: 249
You can use also this plugin, to manipulate the form to use AJAX. In this way the page will not be reloaded. JQuery Ajax Form
To store the user data use cookies or if you want to do this on the server side use a session.
Upvotes: 0
Reputation: 8699
This is something that is usually handled server side. However, if you want to do it with javascript you can set and get cookies. This plugin for jQuery is a popular and easy to use solution.
Upvotes: 0
Reputation: 10718
If you're not wanting to add any backend code then your only choice would be to store the information in a cookie.
http://www.quirksmode.org/js/cookies.html
Upvotes: 3