Created
January 24, 2012 20:22
-
-
Save glynrob/1672339 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function autosave(last) | |
{ | |
if (typeof t!="undefined") {clearTimeout(t);} // reset timer | |
var data = new Object(); | |
var interests = new Object(); | |
var interestscount = 0; | |
$('#myform input,#myform textarea,#myform select').each(function(index) { | |
if ($(this).is(':submit')){ | |
// ignore submit buttons | |
} else { | |
if ($(this).is(':checkbox')){ | |
if ($(this).attr('checked')){ | |
data[$(this).attr('name')] = $(this).val(); | |
} else { | |
data[$(this).attr('name')] = '0'; | |
} | |
} else { | |
if ($(this).attr('name') == 'interests[]'){ // if input is an array | |
interests[interestscount] = $(this).val(); | |
interestscount = interestscount + 1; | |
} else { // if normal input | |
data[$(this).attr('name')] = $(this).val(); | |
} | |
} | |
} | |
data['interests'] = interests; | |
}); | |
// AJAX CALL ADDED HERE | |
} | |
//--> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment