I am using the Bootstrap Multiselect to create a dropdown that would allow the user to select more than 1 item in the dropdown. Here is the link:
http://www.aspsnippets.com/Articles/Multiple-Select-MultiSelect-DropDownList-with-CheckBoxes-in-ASPNet-using-jQuery.aspx
I have JavaScript functions for selecting all items when page loads, deselecting all items, and programmatically selecting specific items in the dropdown. Right now these functions are specific to a certain control. How do I change these functions so they can be used for more than 1 control?
Here is my code:
<script type="text/javascript">
var mainConfigurationSet = {
includeSelectAllOption: true,
enableFiltering: true,
numberDisplayed: 0,
enableCaseInsensitiveFiltering: true
};
var SelectAllConfigurationSet = {
includeSelectAllOption: true,
numberDisplayed: 0
};
function rebuildMultiselectPartType(options) {
$('#lstPartType').multiselect('setOptions', options);
$('#lstPartType').multiselect('rebuild');
}
function rebuildMultiselectAPVDWorkctrs(options) {
$('#lstAPVDWrkctrCode').multiselect('setOptions', options);
$('#lstAPVDWrkctrCode').multiselect('rebuild');
}
function rebuildMultiselectPartNbrs(options) {
$('#lstPartNbr').multiselect('setOptions', options);
$('#lstPartNbr').multiselect('rebuild');
}
function DoSelectAllPartTypes() {
//some code here
$('#lstPartType').multiselect('selectAll', false);
$('#lstPartType').multiselect('updateButtonText');
rebuildMultiselectPartType(SelectAllConfigurationSet);
}
function DoSelectAllAPVDWorkctrs() {
//some code here
$('#lstAPVDWrkctrCode').multiselect('selectAll', false);
$('#lstAPVDWrkctrCode').multiselect('updateButtonText');
rebuildMultiselectAPVDWorkctrs(SelectAllConfigurationSet);
}
function DoSelectAllPartNbrs() {
//some code here
$('#lstPartNbr').multiselect('selectAll', false);
$('#lstPartNbr').multiselect('updateButtonText');
rebuildMultiselectPartNbrs(mainConfigurationSet);
}
function deSelectAllPartNbrs() {
//some code here
$('#lstPartNbr').multiselect('deselectAll', false);
$('#lstPartNbr').multiselect('updateButtonText');
rebuildMultiselectPartNbrs(mainConfigurationSet);
}
function SelectPartTypes() {
//some code here
var i;
for (i = 0; i < arguments.length; i++) {
$('#lstPartType').multiselect('select', [arguments[i]]);
}
rebuildMultiselectPartType(SelectAllConfigurationSet);
}
function SelectAPVDWorkctrs() {
//some code here
var i;
for (i = 0; i < arguments.length; i++) {
$('#lstAPVDWrkctrCode').multiselect('select', [arguments[i]]);
}
rebuildMultiselectAPVDWorkctrs(SelectAllConfigurationSet);
}
function SelectPartNbrs() {
//some code here
var i;
for (i = 0; i < arguments.length; i++) {
$('#lstPartNbr').multiselect('select', [arguments[i]]);
}
rebuildMultiselectPartNbrs(mainConfigurationSet);
}
<td class="auto-style50">
Part Type:
</td>
<td class="auto-style54" colspan="2">
<asp:ListBox ID="lstPartType" runat="server" SelectionMode="Multiple">
<asp:ListItem>BLANKING</asp:ListItem>
<asp:ListItem>CUT-TO-LENGTH</asp:ListItem>
</asp:ListBox>
</td>
<td class="auto-style57">
</td>