| Author |
JavaScript-Retrieve Multiple Values from DropDown
|
Thakur Sachin Singh
Ranch Hand
Joined: Jun 15, 2010
Posts: 205
|
|
Hello All
i want to retrieve more than one selected value from the dropdown in javascript code but unable to retrieve more value, can anyone give me the idea??
please give me suggestion.
|
SCJP 6- 91%, IBM DB2, IBM RAD Certified
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50693
|
|
As a dropdown can have only one selected value, I'm not sure what "other" value you'd want to retrieve.
Or are you talking about a select-list rather than a dropdown?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Thakur Sachin Singh
Ranch Hand
Joined: Jun 15, 2010
Posts: 205
|
|
|
yes i m talking about select list. can you give me any idea?
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50693
|
|
Well, you can loop through the list of options and collect the values of the ones with the selected attribute.
Or you can make your life easier and use jQuery: the expression $('mySelectList').val() will result in an array of all the selected values.
|
 |
Thakur Sachin Singh
Ranch Hand
Joined: Jun 15, 2010
Posts: 205
|
|
actually i do not know the JQuery so will focus on java script. please see my below code. is this code wrong? from this code i am not retrieving values.
|
 |
Thakur Sachin Singh
Ranch Hand
Joined: Jun 15, 2010
Posts: 205
|
|
|
here lmaOther.length return value only 1 and lmaOther[i].selected gives undefined, any idea when these value come?
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
Because
is a reference to the SELECT element, not the OPTIONS
Eric
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50693
|
|
|
P.S. jQuery is JavaScript.
|
 |
 |
|
|
subject: JavaScript-Retrieve Multiple Values from DropDown
|
|
|