Ed James
Ed James

Reputation: 10607

Getting the values in a dropdownbox from javascript

Does anyone know how to get the values from an asp dropdownbox (not just the selected one) using javascript?

Upvotes: 0

Views: 106

Answers (1)

Quentin
Quentin

Reputation: 943571

Assuming you mean a <select> element - just loop over its options property.

var options = refToMyForm.elements.mySelect.options;
for (var i = 0, j = options.length; i < j; i++) {
    var option = option[i];
    var value = option.value;
}

Upvotes: 5

Related Questions