Every line of 'javascript add options to select dynamically' 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.
191 function addSelectOption(optionId, disabled) { 192 193 // add an <option> to the <select> 194 // used only by buildSelect() 195 196 if(disabled == undefined) var disabled = false; 197 198 var jQueryO = jQuery('#' + optionId); 199 var jQueryoption = jQuery("<option>" + jQueryO.text() + "</option>") 200 .val(jQueryO.val()) 201 .attr('rel', optionId); 202 203 if(disabled) disableSelectOption(jQueryoption); 204 205 jQueryselect.append(jQueryoption); 206 }
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
191 function addSelectOption(optionId, disabled) { 192 193 // add an <option> to the <select> 194 // used only by buildSelect() 195 196 if(disabled == undefined) var disabled = false; 197 198 var $O = $('#' + optionId); 199 var $option = $("<option>" + $O.text() + "</option>") 200 .val($O.val()) 201 .attr('rel', optionId); 202 203 if(disabled) disableSelectOption($option); 204 205 $select.append($option); 206 }
1 function add_options_to_select($select, opt_list, selected_val) { 2 for (var i = 0; i < opt_list.length; i++) { 3 var $opt = $('<option />').val(opt_list[i][0]).text(opt_list[i][1]); 4 if (opt_list[i][0] === selected_val) { 5 $opt.prop("selected", true); 6 } 7 $select.append($opt); 8 } 9 return $select; 10 }
81 function selectCallback(value, index) { 82 $(".demo .callback_output").prepend("<p>VALUE: " + value + ", INDEX: " + index + "</p>"); 83 }
3 function appendOption ($select, option) { 4 $select.append($('<option></option>') 5 .attr('value', option.id).text(option.text)); 6 }
95 function populateSelectOptions() { 96 var $select = $('#interactive-image-bit-comparer-selected-image'); 97 for (var i = 0; i < ImageBitComparer.INITAL_IMAGES.length; i++) { 98 var file = ImageBitComparer.INITAL_IMAGES[i][0]; 99 var text = ImageBitComparer.INITAL_IMAGES[i][1]; 100 $select.append($('<option>').text(text).data('file', file)); 101 } 102 };
45 function addOption(select, name, value) { 46 var newOption = document.createElement("option"); 47 newOption.text = name; 48 newOption.value = value; 49 select.add(newOption); 50 }
55 addOption(select: HTMLSelectElement, optionText: string) { 56 var option = document.createElement('option'); 57 option.text = optionText; 58 select.options.add(option); 59 }
37 generateSelectOptions() { 38 let result = []; 39 let options = [ 40 { 41 value: 'none', 42 label: 'None' 43 }, 44 { 45 value: 'good', 46 label: 'Good' 47 }, 48 { 49 value: 'info', 50 label: 'Info' 51 }, 52 { 53 value: 'warn', 54 label: 'Warn' 55 }, 56 { 57 value: 'danger', 58 label: 'Danger' 59 } 60 ]; 61 options.forEach(opt => { 62 result.push( 63 <option key={Uuid.random()} value={opt.value}> 64 {opt.label} 65 </option> 66 ); 67 }); 68 return result; 69 }
227 function generateMultivalueSelectScript(el) { 228 return appendScript(el, multivalueselectTemplate(), generatedNonExecuteScriptClass, multiValueSelectScriptType); 229 }