ronpenrose
asked on
Getting Selected Listbox Items in Javascript
I am cannot figure out how to get multiple selected items in a listbox on ASP page. I am using document.Form1.lstMyList.O ptions(i). value but each item value is empty.
example code
for (i=0;i<document.Form1.lstM yList.Leng th;i++) {
if document.Form1.lstMyList.o ptions(i). selected = true) {
alert(document.Form1.lstMy List.Optio ns(i).valu e);
}
example code
for (i=0;i<document.Form1.lstM
if document.Form1.lstMyList.o
alert(document.Form1.lstMy
}
And remember that Javascript is case-sensitive, so ".Length" should be ".length" and ".Options(i)" should be ".options".
Also, if you are trying to compare to see if two values are equal, it should be "==" instead of "="
Also, if you are trying to compare to see if two values are equal, it should be "==" instead of "="
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
for (i=0; i < document.Form1.lstMyList.l
{
if (document.Form1.lstMyList.
{
alert(document.Form1.lstMy
}
}