File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes JavaScript-Retrieve Multiple Values from DropDown Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JavaScript-Retrieve Multiple Values from DropDown" Watch "JavaScript-Retrieve Multiple Values from DropDown" New topic
Author

JavaScript-Retrieve Multiple Values from DropDown

Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232


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 ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

yes i m talking about select list. can you give me any idea?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

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: 232

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: 232

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: 15376
    
    6
Because


is a reference to the SELECT element, not the OPTIONS



Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

P.S. jQuery is JavaScript.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaScript-Retrieve Multiple Values from DropDown
 
Similar Threads
dynamically change value of id in td
Session attributes
dynamically change value of id in td
dynamically change value of id in td
javascript