I am currently trying to figure out how to edit the below script to convert a list from a check list to a multi select drop down list if it is possible. Any help that can be offered is appreciated.
function checkCheckBoxList(oSrc, args) {
var isValid = false;
$("#<%= cklLocations.ClientID %> input[type='checkbox']:checked").each(function (i, obj) {
isValid = true;
});
args.IsValid = isValid;
}
You can map the checked checkboxes
const $dropdown = $("#dropdown");
const $checks = $("#cklLocations input[type='checkbox']").on("click", function() {
$dropdown[0].length = 1; // remove all but first
const opts = $("#cklLocations input[type='checkbox']:checked").map(function() {
return `<option value="${this.value}">${this.name}</option>`
}).get().join("")
$dropdown.append(opts)
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="cklLocations">
<label>A<input type="checkbox" name="A" value="a" /></label>
<label>B<input type="checkbox" name="B" value="b" /></label>
<label>C<input type="checkbox" name="C" value="c" /></label>
<label>D<input type="checkbox" name="D" value="d" /></label>
</div>
<select id="dropdown" multiple>
<option disabled>Please select</option>
</select>