r k

r k

  • NA
  • 111
  • 15k

HTML Multi Select Options

Apr 13 2021 9:35 PM
I have this multiselect dropdown 
 
<select id="ddlCustomers" class=" form-control input-sm selectType country" name="ddlDtype" multiple="multiple" size="7" > 
when user selects  multiple options Example 2,3,4 
Then I am saving like this  
var countries = [];
$.each($(".country option:selected"), function(){
countries.push($(this).val());
});
 and  save to DB 
with var country= countries.join(", ");
 
Now when a user comes & edits these multi-select saved values  I want these pre-saved options 2,3,4 should be selected & rest in the list to be unselected so that the user can modify its choice & can select any other items from the option 
 For saving, I have bootstrap modal pop with this HTMLselect option & other controls. after save they appear in a grid view, in grid view on each row id user can edit the select options in another modal pop and saves edited values in DB. 
Please help 
 

Answers (2)