Skip to content

Instantly share code, notes, and snippets.

@nicferrier
Created August 29, 2012 10:29
make a query string from a form with bonzo
function form_to_qs(form) {
var qs = "";
var fields_array = $(form[0].elements);
fields_array.each(
function (e,i){
var pair = e.name + "=" + encodeURIComponent(e.value);
qs = qs + pair + ((i < fields_array.length - 1)?"&":"");
}
);
return qs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment