Whenever the drop-down selection changes, I want to dynamically update a list group box by replacing all existing items with new ones.
Here's the code for the list group box:
<select style="max-height: 30vh; min-height: 30vh; width: 100%; border: 0;"
multiple="multiple"
class="list-group list-group-available-items overflow-auto">
@foreach (var listGroupOption in Model.OrderItems ?? new List<SelectListItem>())
{
<option value="@listGroupOption.Value" class="list-group-item">
@listGroupOption.Text
</option>
}
</select>
Below is my JavaScript attempt at achieving this functionality:
$('#ddlRegion').change(function (e) {
$(".list - group - available - items")
.find('option')
.remove();
});