Reputation: 5386
I have a list of textboxes created dynamically accroding to the user selection on aspx page.
I want to get and store into an array the value of these using Jquery, javascript.
how can i do that?
is it possible to loop through all the textboxes in a page?
Thanks
Upvotes: 0
Views: 1368
Reputation: 187040
var values = new Array();
$(":text").each(function(){
values.push ( this.value );
});
Upvotes: 0
Reputation: 342635
You can use map
to succinctly grab all the values:
var values = $("input[type=text]").map(function() {
return this.value; // or $(this).val()
}).get();
Loop over all textboxes using each
:
var values = [];
$("input[type=text]").each(function() {
values.push(this.value);
});
Upvotes: 2