0

Select box

<select id="update-select" multiple="multiple">
  <option value="3">Test1 </option>
  <option value="4">Test2 </option>
  <option value="5">Test3 /option>
  <option value="6">Test4</option>
  <option value="15">Test5</option>
</select>

I am selecting the options from another jquery click function based on some manipulation .

(say i have selected values 3 and 4)

later i want to see the values of selected option

i tried,

selectedVals = $("#update-select option:selected").val() ;
alert(selectedVals) // alerts 3

it shows only the first value selected.

Any suggestion?

zzlalani
  • 22,960
  • 16
  • 44
  • 73
monda
  • 3,809
  • 15
  • 60
  • 84
  • 4
    Possible duplicates http://stackoverflow.com/questions/3243476/how-to-get-multiple-select-box-values-using-jquery – Krish R Nov 25 '13 at 06:52

2 Answers2

3

this should do

selectedVals = $("#update-select").val() ;
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
0

You should use:

$("#update-select option:selected").each(function(i,elem){
   alert($(elem).val());
});

Here's an example: http://jsfiddle.net/5jNWY/

Hope this helps!

Rob Angelier
  • 2,335
  • 16
  • 29