Skip to content Skip to sidebar Skip to footer

How To Read Input Two Dimensional Array Value In Jquery?

I have a form to add many contacts in html the input is two dimensional array here is the form:

but i want to return an input value of account name or account email or account mobile for this you can use .serializeArray();

$('pre').html(JSON.stringify($('.form-control').serializeArray(), 0, 3));
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><pre></pre><inputclass="form-control"type="text"name="account[0][name]"placeholder="Name"autocomplete="off" /><inputclass="form-control"type="text"name="account[0][email]"placeholder="Email"autocomplete="off" /><inputclass="form-control"type="text"name="account[0][mobile]"placeholder="Mobile"autocomplete="off" /><inputclass="form-control"type="text"name="account[1][name]"placeholder="Name"autocomplete="off" /><inputclass="form-control"type="text"name="account[1][email]"placeholder="Email"autocomplete="off" /><inputclass="form-control"type="text"name="account[1][mobile]"placeholder="Mobile"autocomplete="off" />

Solution 2:

You can use the starts with and ends with attribute selectors:

$('[name^="account"][name$="[name]"]')

Would select all elements where the name starts with account and ends with [name].

Solution 3:

Try this.

$('input[name^="account"]').each(function() {
  alert($(this).val());
});
<scriptsrc="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script><inputclass="form-control"type="text"value="test"name="account[0][name]"placeholder="Name"autocomplete="off" /><inputclass="form-control"type="text"value="test@gmail.com"name="account[0][email]"placeholder="Email"autocomplete="off" /><inputclass="form-control"type="text"value="1234568790"name="account[0][mobile]"placeholder="Mobile"autocomplete="off" /><inputclass="form-control"type="text"value="test2"name="account[1][name]"placeholder="Name"autocomplete="off" /><inputclass="form-control"type="text"value="test2@gmail.com"name="account[1][email]"placeholder="Email"autocomplete="off" /><inputclass="form-control"type="text"value="3216549870"name="account[1][mobile]"placeholder="Mobile"autocomplete="off" />

Post a Comment for "How To Read Input Two Dimensional Array Value In Jquery?"