Click here to Skip to main content
15,921,295 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have using one multi select in mvc application

 <select style="width:100%" class="select" id="Days" name="Days" multiple="multiple">
<option value='Sunday'>Sunday</option>
<option value='Monday'>Monday</option>
<option value="Tuesday">Tuesday</option>
<option value="Wednesday">Wednesday</option>
<option value="Thursday">Thursday</option>
<option value="Friday">Friday</option>
<option value="Saturday">Saturday</option>
</select>


After select few values and stored backend. it's working,
my problem : when i try to retrive the value to bind in select box
but can't selected

What I have tried:

i try like this

var days='Sunday';
$('#Days').val(days);
Posted
Updated 4-Jan-18 21:03pm
Comments
Chirag Sudra 5-Jan-18 2:22am    
Go through jQuery Selector

http://api.jquery.com/selected-selector/

try

var selectedDays = ['Sunday', 'Monday'];
          $('#Days option').each(function (a, option) {
              option.selected = selectedDays.indexOf(option.value) > -1;
          });

Demo:Plunker[^]
 
Share this answer
 
v2
Hi,
Thank you for your reply..

as per your solution is already working to me. my issues now
When i click button and passed some values like 'Sunday','Monday' but can not selected that value in multi select drop down.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900