Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  17] [ 7]  / answers: 1 / hits: 43511  / 12 Years ago, mon, december 17, 2012, 12:00:00

I need to get values of all textboxes with same name attributes using jquery.



<input type=text id=text1 name=text[]>
<input type=text id=text2 name=text[]>
<input type=text id=text3 name=text[]>


How can I get all values of textbox text[] and compare it using jquery.



I tried using



 var values = $(input[name='text[]'])
.map(function(){return $(this).val();}).get();


but am no successful.


More From » jquery

 Answers
3

You can use map method and store the values into an array.



$(function(){
var values = $('input[name=text[]]').map(function(){
return this.value
}).get()
})


http://jsfiddle.net/UugWW/


[#81379] Saturday, December 15, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kamronr

Total Points: 749
Total Questions: 110
Total Answers: 122

Location: Dominica
Member since Sat, Nov 5, 2022
2 Years ago
kamronr questions
Mon, Dec 21, 20, 00:00, 3 Years ago
Fri, Oct 16, 20, 00:00, 4 Years ago
Sat, Oct 3, 20, 00:00, 4 Years ago
Sun, Jul 28, 19, 00:00, 5 Years ago
;