I'm trying to create a multiselect dropdown menu for toggling which campus information is visible and came across David Stutz's bootstrap plugin.
I called in my links and scripts:
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-multiselect.js"></script>
<link rel="stylesheet" href="css/bootstrap-multiselect.css" type="text/css" />
I created my dropdown menu
<select id="campusMultiSelect"
multiple="multiple">
<option value="Campus1">Campus 1</option>
<option value="Campus2">Campus 2</option>
<option value="Campus3">Campus 3</option>
</select>
The id in the sections to be toggled
<div id="Campus1"
class="rounded">
// Campus 1 information goes here
</div>
// <div> for Campus 2 and 3 go here
And the javascript
<script type="text/javascript">
$(function () {
$('#campusMultiSelect').multiselect({
includeSelectAllOption: true
});
$('#campusMultiSelect').change(function () {
// Get the selected values
var selectedValues = $(this).val();
// Define an array of campus IDs to toggle
var campusIDs = ['Campus1', 'Campus2', 'Campus3'];
// Iterate through the campus IDs and toggle their visibility
campusIDs.forEach(function (campusID) {
var showContent = selectedValues &&
selectedValues.indexOf(campusID) !== -1;
$('#' + campusID).toggle(showContent);
});
});
});
</script>
However, when I run it, this is the box that I get as opposed to the one I'm supposed to get with selection boxes next to each option
I followed all of the instructions in the documentation on use, but obviously didn't get what I was expecting.
The code in the repository was last updated in 2022, so is this multiselect still compatible with current versions of Razor, ASP.NET Core, and C# or am I just making a very obvious mistake and forgot a semicolon or something?


You can check your bootstrap version in the browser's developer tools and check if there are any related error messages. Here are two methods you can choose:
1. If the bootstrap version you are using is V5, you can migrate to v4.
2. Or you can use the corresponding version of bootstrap, but you need to perform relevant initialization configuration on the Bootstrap Multiselect plug-in.
You can use it as a reference with bootstrap5.1.3:
You can see the presentation of Multiselect: