0

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

1 Answer 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;
}
Sign up to request clarification or add additional context in comments.

3 Comments

actually, an <asp:DropDownList/>, but they're effectively the same thing, so thanks =]
I'm assuming you are asking about client-side JavaScript, which only cares about the document that the browser sees. It has no idea about the ASP ... and since I'm not as ASP programmer, I can only guess :) It does help to reduce examples as much as possible.
sorry, I always forget that asp controls are generally just html controls with server side methods, I normally only do ASP programming!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.