Noah Noah - 1 year ago 119
jQuery Question

Elements of form to javascript object using JQuery

What would be the way best to convert form elements to an JavaScript Element?

I would like some automatic way to build JavaScript objects, without having to loop each element. I do not want any strings returned like in

var formData = f.serialize();


<script type="text/javascript">
$(function() {
$("#sendrfr").click(function() {

var f = $("#Commtnx");
var formData = f.serialize();


<div id="outter">
<form id="Commtnx" action="/Home/Test1" method="post" name="down">
<div id="inner">
<input id="input1" type="text" value="2" />

<input type="submit" id="sendrfr" />

Answer Source

serializeArray() does just that.

    var output = $(this).serializeArray();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download