Click here to Skip to main content
14,236,064 members

Multi-select Check Box List or Checkbox Dropdown with Select All Option

Rate this:
3.67 (5 votes)
Please Sign up or sign in to vote.
3.67 (5 votes)
11 Jul 2019CPOL
How to create a checkbox list using simple HTML and jQuery

Introduction

Check Box list is useful to allow the user to select multiple options in a select box. But in this case, multiple options can be selected by holding down the control (ctrl) button and the user hates that. Instead of using the multiple attributes in HTML, you can use jQuery to make the multi-select checkbox dropdown.

This is a simple HTML Control with jQuery & CSS that you can use in any web programming language.

Live Demo

Using the Code

I wrote an extension method using jQuery, you can define your dropdown select control and call CreateMultiCheckBox method.

This method will simply convert your select control into multi-select checkbox list control.

<select id="test">
  <option value="1">American Black Bear</option>
  <option value="2">Asiatic Black Bear</option>
  <option value="3">Brown Bear</option>
  <option value="4">Giant Panda</option>
  <option value="5">Sloth Bear</option>
  <option value="6">Sun Bear</option>
  <option value="7">Polar Bear</option>
  <option value="8">Spectacled Bear</option>
</select>

Convert Select Into Multi Select Checkbox

Here "test" is your control id, you can also pass default options, such as width, height & default title of control.

$(document).ready(function () {
  $("#test").CreateMultiCheckBox({ width: '230px',
             defaultText : 'Select Below', height:'250px' });
});

Download

I put CSS and jquery on the same page, you can separate according to your project. Here is the full download TestMultiCheckbox.zip .

History

  • 11th July, 2019: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Thiagarajan Rajendran
Architect
United States United States
No Biography provided

Comments and Discussions

 
QuestionInprovment Pin
Klaus Kurzawa12-Jul-19 18:55
memberKlaus Kurzawa12-Jul-19 18:55 
QuestionDownload code link not working Pin
Tom-Sacramento12-Jul-19 9:17
memberTom-Sacramento12-Jul-19 9:17 
QuestionDownload link no work Pin
Edward Ocando12-Jul-19 6:03
groupEdward Ocando12-Jul-19 6:03 
GeneralMy vote of 5 Pin
jgakenhe12-Jul-19 3:24
professionaljgakenhe12-Jul-19 3:24 
PraiseMulti-select check box Pin
Member 1416447312-Jul-19 1:22
memberMember 1416447312-Jul-19 1:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Tip/Trick
Posted 11 Jul 2019

Stats

2.3K views
38 downloads
3 bookmarked