You cannot check the box inside the select element, but you can get the same functionality using HTML, CSS and JavaScript. Here is a possible working solution. The explanation is as follows.

The code:
var expanded = false; function showCheckboxes() { var checkboxes = document.getElementById("checkboxes"); if (!expanded) { checkboxes.style.display = "block"; expanded = true; } else { checkboxes.style.display = "none"; expanded = false; } }
.multiselect { width: 200px; } .selectBox { position: relative; } .selectBox select { width: 100%; font-weight: bold; } .overSelect { position: absolute; left: 0; right: 0; top: 0; bottom: 0; } #checkboxes { display: none; border: 1px #dadada solid; } #checkboxes label { display: block; } #checkboxes label:hover { background-color: #1e90ff; }
<form> <div class="multiselect"> <div class="selectBox" onclick="showCheckboxes()"> <select> <option>Select an option</option> </select> <div class="overSelect"></div> </div> <div id="checkboxes"> <label for="one"> <input type="checkbox" id="one" />First checkbox</label> <label for="two"> <input type="checkbox" id="two" />Second checkbox</label> <label for="three"> <input type="checkbox" id="three" />Third checkbox</label> </div> </div> </form>
Explanation:
First, we create a select element that displays the text "Select a option", and an empty element that covers (overlaps) the select element ( <div class="overSelect"> ). We do not want the user to click on the select element - it would display empty options. To overlap an element with another element, we use the CSS position property with a value of relative | absolute.
To add functionality, we specify a JavaScript function that is called when the user clicks on the div element containing our select element ( <div class="selectBox" onclick="showCheckboxes()"> ).
We also create a div that contains our checkboxes and style it with CSS. The above JavaScript function simply changes the value of the <div id="checkboxes"> CSS display property from "none" to "block" and vice versa.
The solution was tested in the following browsers: Internet Explorer 10, Firefox 34, Chrome 39. JavaScript must be enabled in the browser.
Additional Information:
CSS positioning
How to overlay one div on another div
http://www.w3schools.com/css/css_positioning.asp
CSS display property
http://www.w3schools.com/cssref/pr_class_display.asp
vitfo Dec 18 '14 at 12:50 2014-12-18 12:50
source share