10 examples of 'jquery change select option ajax' in JavaScript

Every line of 'jquery change select option ajax' 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
191function 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}
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

191function 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}
37function loadCascadedSelects(){
38 var cascadeForm = $('#theForm');
39 var subcounty = cascadeForm.find('#subcounty');
40 var village = cascadeForm.find('#village');
41 cascadeSelect(subcounty, village);
42}
131function changeSelect(_target,_val1,_val2)
132{
133 var val = _target.find('ul li');
134 var selectedOption = $(val[_val1]).children()[_val2];
135
136 if(_target.hasClass('multiOption'))
137 {
138 val = _target.find('ul li')[_val1];
139 selectedOption = $(val).children()[_val2];
140 }
141
142 var selectbox = _target.parent().find('.select');
143 var target = _target.parent().find('.select .value')[0];
144 if(target==undefined) target = selectbox[0];
145
146 if(!selectbox.hasClass('fixedVal'))
147 {
148 target.innerHTML = selectedOption.innerHTML;
149 $(_target).parent().attr('value', _val1);
150 }
151 _target.trigger('change');
152
153 $(val).find('.active').removeClass('active');
154 $(selectedOption).addClass('active');
155
156 if(!_target.hasClass('keepOpened'))
157 toggleDropdown(_target, true);
158}
229function enableSelectOption($option) {
230
231 // given an already disabled select option, enable it
232
233 $option.removeClass(options.optionDisabledClass)
234 .attr("disabled", false);
235
236 if(options.hideWhenAdded) $option.show();
237 if($.browser.msie) $select.hide().show(); // this forces IE to update display
238}
47function onChangeSelect(option) {
48 setValue(option.value)
49}
179function setSelectState(val) {
180
181 if (isBooleanSelect) {
182 if (val) {
183 mdcSelect.selectedIndex = 1;
184 mdcList.selectedIndex = 1;
185 $this.find('.mdc-select__icon').attr('src', myMdwHelper.getValueFromData(data.imageTrue, ''))
186 } else {
187 mdcSelect.selectedIndex = 0;
188 mdcList.selectedIndex = 0;
189 $this.find('.mdc-select__icon').attr('src', myMdwHelper.getValueFromData(data.image, ''))
190 }
191 } else {
192 for (var i = 0; i <= data.values; i++) {
193 if (val.toString() === myMdwHelper.getValueFromData(data.attr('value' + i), '').toString()) {
194 mdcSelect.selectedIndex = i;
195 mdcList.selectedIndex = i;
196 $this.find('.mdc-select__icon').attr('src', myMdwHelper.getValueFromData(data.attr('menuIcon' + i), ''))
197
198 break;
199 }
200 }
201 }
202};
110function selectOption(sSelectSelector, sOption, callback) {
111 zBrowser.select(sSelectSelector, sOption);
112 callback();
113}
4function updateSelect(data, selector, id_attr, value_attr) {
5 var _select_tag = $(selector)[0];
6 var new_options = '';
7
8 // in some cases, e.g. TestRun search, the 1st <option> element is ---
9 // which must always be there to indicate nothing selected
10 if (_select_tag.options.length) {
11 new_options = _select_tag.options[0].outerHTML;
12 }
13
14 data.forEach(function(element) {
15 new_options += '<option value="' + element[id_attr] + '">' + element[value_attr] + '</option>';
16 });
17
18 _select_tag.innerHTML = new_options;
19
20 try {
21 $(selector).selectpicker('refresh');
22 } catch(e) {
23 console.warn(e);
24 }
25}
234function multipleSelect(mode){
235 var element_id = parseInt($("#multipleSelectionTool").data('img_container_id').split("___")[1]);
236 $(".img_container").each(function(){
237 if(!$(this).hasClass("image_selected")){
238
239 // Update the session list
240 updateListSession($(this).attr("id"), "selected", "gallery")
241
242 if (mode=='all'
243 || (mode=='from' && $(this).attr('id').split("___")[1]>element_id)
244 || (mode=='to' && $(this).attr('id').split("___")[1]<element_id)) {
245 $(this).addClass("image_selected")
246 }
247 }
248
249 })
250}

Related snippets