Reputation: 124
This is how i have written my values.
<input type='text' class='textVerdana11' style='text-align:right' id='test1' name='test[]' value='1' />
<input type='text' class='textVerdana11' style='text-align:right' id='test2' name='test[]' value='2' />
<input type='text' class='textVerdana11' style='text-align:right' id='test3' name='test[]' value='3' />
Now the problem at hand is that i have to extract the values by name because the id
s can be anything in jQuery or JavaScript.
Upvotes: 1
Views: 70
Reputation: 133453
Attribute Equals Selector [name="value"] can be used to select elements, then map()
to create an array of values.
var array = $('[name="test[]"]').map(function() {
return $(this).val();
}).get();
Upvotes: 4
Reputation: 8320
I think, something like this should work
$('[name="test[]"]').each(function() {
return $(this).val();
}).get()
Upvotes: 1
Reputation: 105
you can use like this :
$(function(){
var values = $("input[name='test\\[\\]']")
.map(function(){return $(this).val();}).get();
alert(values);
});
Upvotes: 1