Reputation:
I checked out the jquery serialize docs and I am trying to find the best way too serialize all fields in my form and then print the output, the demo has something like:
function showValues() {
var str = $("form").serialize();
$("#results").text(str);
}
$(":checkbox, :radio").click(showValues);
$("select").change(showValues);
showValues();
});
Even then call the serialize on form submit, use return false and have it show them.
Thoughts?
Upvotes: 0
Views: 975
Reputation: 17548
Are you putting inside the document.ready method? It looks like you are ending that way... It should be like:
$(function() {
$(":checkbox, :radio").click(showValues);
$("select").change(showValues);
$('form').bind('submit',function() { showValues(); return false; });
showValues();
});
function showValues() {
var str = $("form").serialize();
$("#results").text(str);
}
Upvotes: 0