Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created with JetBrains WebStorm.
- * User: ynonperek
- * Date: 8/26/12
- * Time: 9:54 AM
- * To change this template use File | Settings | File Templates.
- */
- $(function() {
- var contact = {};
- function save() {
- console.log('save');
- contact.name = $('#name').val();
- contact.number = $('#number').val();
- contact.email = $('#email').val();
- contact.color = $('#color').val();
- contact.gender = $('#gender').val();
- localStorage.setItem('data', JSON.stringify(contact));
- }
- function restore() {
- var saved_value = localStorage.getItem('data');
- if ( saved_value ) {
- contact = JSON.parse( saved_value );
- }
- show_all();
- }
- function show_all() {
- $('#name' ).val( contact.name );
- $('#number').val( contact.number );
- $('#email' ).val( contact.email );
- $('#color' ).val( contact.color );
- $('#gender').val( contact.gender );
- }
- $('#save').click( save );
- $('form').on('input', save );
- $('#restore').click( restore );
- $('form').submit(function() {
- return false;
- });
- restore();
- });
Add Comment
Please, Sign In to add comment