Single select boxes
Select2 can take a regular select box. By default it supports all options and operations that are available in a standard select box,but with added flexibility.
Multiple select boxes
Select2 also supports multi-value select boxes. The select below is declared with the multiple attribute. We can select multiple data in One time.
Select2 will correctly handle disabled results, both with data coming from a standard select (when the disabled attribute is set) and from remote sources, where the object has disabled: true set.
Limiting the number of selections
Select2 multi-value select boxes can set restrictions regarding the maximum number of options selected. The select below is declared with the multiple attribute with maximumSelectionLength.
Select2 supports custom themes using the theme option so you can style Select2 to match the rest of your application.These examples use the classic theme.
A placeholder value can be defined and will be displayed until a selection is made. Select2 uses the placeholder attribute on multiple select boxes
Dynamic Option Creation
In addition to a prepopulated menu of options, Select2 can dynamically create new options from text input by the user in the search box. This feature is called "tagging". To enable tagging, set the tags option to true:
Multi value Select Boxes
Tagging can also be used in multi-value select boxes. In the example below, we set the multiple="multiple" attribute on a Select2 control that also has tags: true enabled:
Automatic Tokenization into tags
Select2 supports ability to add choices automatically as the user is typing into the search field. Try typing in the search field below and entering a space or a comma. The separators that should be used when tokenizing can be specified using the tokenSeparators options.