showing results for - "reset select dropdown javascript"
Giulia
16 Jan 2021
1     var courses = document.getElementById("special_selection");
2
3    // clear select
4    var length = courses.options.length;
5    for (i = length - 1; i >= 0; i--) {
6      courses.options[i] = null;
7    }
8    for (var i = 0; i < data.length; i++) {
9      var option = document.createElement("OPTION"),
10          txt = document.createTextNode(data[i].coursetitle);
11      option.appendChild(txt);
12      option.setAttribute("value", data[i].KF);
13      courses.insertBefore(option, courses.lastChild);
14
15    }
Reuben
25 Oct 2020
1$('#id').val('1');
2$('#id').trigger('change');
3
Ewenn
02 Apr 2019
1var courses = document.getElementById("special_selection");
2
3    // clear select
4    var length = courses.options.length;
5    for (i = length - 1; i >= 0; i--) {
6      courses.options[i] = null;
7    }
8    for (var i = 0; i < data.length; i++) {
9      var option = document.createElement("OPTION"),
10          txt = document.createTextNode(data[i].coursetitle);
11      option.appendChild(txt);
12      option.setAttribute("value", data[i].KF);
13      courses.insertBefore(option, courses.lastChild);
14
15    }
queries leading to this page
html clear out a select fieldjavascript clear select optionsjavascript select2 resetjs reset select elementreset select tag jshow to clear a select drop down htmlselect box clear jshow to clear select dropdown using reset htmljs empty select listclear select all in js treeclear combobox in javascriptjs reset selectionhow to clear an dropdown element in javascriptclear all options from select javascripthow to reset select box value in javascriptextjs clear combobox selectionclear select html javascriptback button reset select value javascriptreset dropdown option with javascripthtml select element remove all optionsjavascript clear all options from selectreset select element options to original list jsreset dropdown jsclick on select reset the selectjs clear selected optionhow to clear option in select javascriptrad combo box clear selected index javascripthow to clear dropdown selection on click button java scriptclear select in js treehow to clear select in javascriptjavascript clear options from selectjavascript reset selecthow to reset selected option on changejavascript reset options in select box to dafaultjavascript show field if select option is selected and clear js remove all select from dropdownclear select in javascripthow to clean select value javascriptjavascript reset select dropdownhow to reset dropdown in jsjavascript remove all options from select drop downreset select option javascriptclear all select options javascriptjs clear select valuereset select selection in htmlhow to clean selected option javascripthow to reset selected option value in javascriptjs select2 clear valuehtml select clear selectionjs clear elements from selectclear selection of dropsown in javascriptjavascript function to reset selectreset select dropdown javascriptclear select dropdown jqueryreset a select in javascriptjs clear selectionradcombobox clear selection javascripthow to clear select options in javascriptdom clear dropdown optionsremove select all options javascriptjs clear select optionsclear select jsjs reset dropdown listjavascript clear select reset isteven select with create custom resetreset select option to default jselement select 28 29 resethow to clear the selected value of dropdown in javascriptselect clear javascriptjavascript select clear selectionhow to clear the selected value under select in javascriptjs reset a select document getelementbyidclear select content javascripthow to reset dropdown optionin jshow to reset dropdown using javascriptreset dropdown list javascripthow to clear the select box value in javascriptclear creatable select value dynmicallyhow to reset select dropdown in jqueryclear select field javascriptclear select dropdown how to clear all options from select jsclear html select using javascriptjs clear options from selectclear selected option javascriptreset select element javascriptreset selectpicker javascriptreset a un select en ja c2 bfvascriptjs select options remove alljavascript clearing select optionsjs clear select set valuejavascript reset select to first optionhow to clear select value in javascriptjavascript form reset for selectclear selected option jsjs clear selection select dropdownclear selection javascriptallow clear on html select javascriptmdn select clear selectionhtml reset select element in jsselect clear options jsclear dropdown javascriptclear select value javascriptclear select box and table javascripthow to reset select option in javascripthtml clear dropdown selectionclear select options javascripthow to reset dropdown selected value in javascript automaticallyjs remove all select optionsreset select on changeclear javascript selectjavascript remove all select optionsjavascript clear dropdown selectionjs how to make a dropdown clear the select when clickedhow to reset dropdown selected value in javascriptjavascript clear selectionjavascript clear selected optionjs reset selection select dropdownreset select2 dropdown jqueryhow to reset the select box on every button clickjs reset selectreset select javascriptselect clear jsreset select jsclear select box javascriptclear selected value dropdown javascriptjavascript reset select valuehow to clear dropdown in jsclear select dropdown jshtml select input resethow to clear selection dropdown list in javascripthow do i reset a select input in jsjavascript select clear optionsreset select dropdown javascript