10 examples of 'jquery multiselect dropdown get selected values' in JavaScript

Every line of 'jquery multiselect dropdown get selected values' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
20function setDropdownValues($dropdown, values, selectedValue) {
21 $dropdown.empty();
22 var optionsAsString = '';
23 // add an empty string to the beginning for empty selection
24 values.unshift('');
25 $.each(values, function () {
26 optionsAsString += "<option value='" + escapeHtml(this) + "'" + (selectedValue == this ? " selected='selected'" : "") + ">" + escapeHtml(this) + "</option>";
27 });
28 $dropdown.append($(optionsAsString));
29}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

211getValue() {
212 const ss = this;
213 return ss.$selectEl.val();
214}
66getSelectedOption(key) {
67 return this.$refs.select2.options[this.selectedIndex()].dataset[key];
68}
286_setSelectedValues() {
287 this.selectedItem = this.shadowRoot.querySelector("#menu").selectedItem;
288 this.selectedItemLabel = this.shadowRoot.querySelector(
289 "#menu"
290 ).selectedItemLabel;
291 this.selectedItemIndex = this.shadowRoot.querySelector("#listbox").selected;
292}
53get allSelected(): boolean {
54 return this.options && this.options.length && !this.anyUnselected;
55}
187isSelected(value) {
188 return this.findSelectionIndex(value) != -1;
189}
130getSelect2Values($selector, default_value = []) {
131 let value = jQuery($selector).select2('val');
132
133 if(value) {
134 return value;
135 } else {
136 return default_value;
137 }
138}
32get currentMultiselectValue() {
33 const option = this.options.options.find(
34 (opt: IListOption<number>) => this.value === opt.value,
35 );
36
37 if (option) return option;
38 if (this.options.allowEmpty) return null;
39 return this.options.options[0];
40}
20selectedOptionsValues() {
21 return $.map(
22 this.props.selectedOptions,
23 (selectedOption) => selectedOption.value
24 );
25}
207private setSingleSelectedOption(option: SelectItem | undefined) {
208 const previous = this.selectedItems.length > 0 ? this.optionsMap[this.selectedItems[0].value] : undefined;
209 this.selected = option ? this.optionsMap[option.value] : undefined;
210 return previous;
211}

Related snippets