Getting the values in a dropdownbox from javascript

时间:2021-08-07 09:51:11

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

有谁知道如何使用JavaScript从asp下拉框(而不仅仅是选定的一个)获取值?

1 个解决方案

#1


5  

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;
}

#1


5  

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;
}