Here is the HTML code:
HTML Form Builder
jQuery has very helpful function called serialize.
Demo: http://jsfiddle.net/55xnJ/2/
//Just type:
$("#preview_form").serialize();
//to get result:
single=Single&multiple=Multiple&multiple=Multiple3&check=check2&radio=radio1
Try this for getting form input text value to JavaScript object...
var fieldPair = {};
$("#form :input").each(function() {
if($(this).attr("name").length > 0) {
fieldPair[$(this).attr("name")] = $(this).val();
}
});
console.log(fieldPair);
The answer already been accepted, I just write a short technique for the same purpose.
var fieldPair = '';
$(":input").each(function(){
fieldPair += $(this).attr("name") + ':' + $(this).val() + ';';
});
console.log(fieldPair);