Get value of inputs with Jquery

arrays, jquery

Solution

var arrInputValues = new Array();
$("input[name='table\\[\\]']").each(function(){
     arrInputValues.push($(this).val()); 
     // you can also use this
     //arrInputValues.push(this.value);
});

Now your arrInputValues contains all the value.

You can also use

$("input[name='table[]']").each(function(){

You can see a working demo

You can use join() method to join the values in the array.

arrInputValues.join(',');

will join the array elements as a string separated by `,`.

Problem

I have 100 inputs with the name `table[]`. How can I get their value with jQuery, as an array? I am trying to do something like `$_POST['table']` in PHP. I tried the following code, but I want the values as an array... ``` $("input[name='table[]']").each(function(){document.write($(this).val());}); ```

Original source