GigaPr
GigaPr

Reputation: 5386

Get values of textboxes created dynamically

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

Answers (2)

rahul
rahul

Reputation: 187040

var values = new Array();
$(":text").each(function(){
    values.push ( this.value );
});

Upvotes: 0

karim79
karim79

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

Related Questions