Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaScript-Retrieve Multiple Values from DropDown

 
Thakur Sachin Singh
Ranch Hand
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Thakur Sachin Singh
Ranch Hand
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i m talking about select list. can you give me any idea?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here lmaOther.length return value only 1 and lmaOther[i].selected gives undefined, any idea when these value come?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because


is a reference to the SELECT element, not the OPTIONS



Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. jQuery is JavaScript.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic