Hayi
Hayi

Reputation: 6246

send all text option in select with request

I use ajax to dynamically populate a drop-down select.

Now i want to send all select option text with my request.

<select name=".." >
 <option value="0"> ... </option>
 <option value="1"> xxx </option>
 <option value="2"> yyy </option>   
 ....
</select>

i want send in request xxx , yyyy , ....

Upvotes: 0

Views: 234

Answers (1)

Anant Dabhi
Anant Dabhi

Reputation: 11114

you can get all text via JQuery $.map is probably the most efficient way to do this.

var options = $('select option');

var values = $.map(options ,function(option) {
    return option.innerText;
});

console.log(values);

Upvotes: 1

Related Questions