Created
August 29, 2012 10:29
-
-
Save nicferrier/3510071 to your computer and use it in GitHub Desktop.
make a query string from a form with bonzo
This file contains 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 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