Skip to content

Instantly share code, notes, and snippets.

@kazzkiq
Created March 17, 2015 20:10
Show Gist options
  • Save kazzkiq/2ebeedc99e8dd383a46c to your computer and use it in GitHub Desktop.
Save kazzkiq/2ebeedc99e8dd383a46c to your computer and use it in GitHub Desktop.
function resultsFromForm(el){
var results = {};
$('.question',el).each(function(){
var iv = $('input:checked', this)[0].value;
if(iv.split("|").length > 1){
var iarray = iv.split("|"), isize = iarray.length, i;
console.log(iarray);
for(i = 0; i < isize; i++){
if(results[iarray[i]] == undefined){
results[iarray[i]] = 1;
}else{
results[iarray[i]]++;
}
}
}else{
if(results[iv] == undefined){
results[iv] = 1;
}else{
results[iv]++;
}
}
});
console.log(results);
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment