clear select dropdown js

Solutions on MaxInterview for clear select dropdown js by the best coders in the world

showing results for - "clear select dropdown js"
Elizabeth
15 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    }
Oli
30 Nov 2018
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
javascript clear select optionsclick on select reset the selectjs reset select elementjavascript select clear selectionhow to clear the select box value in javascriptclear select box javascriptreset select2 dropdown jqueryreset select jshow to clean selected option javascriptreset select dropdown javascriptjs select options remove allclear javascript selecthtml select clear selectionhow to clear dropdown in jsclear select dropdown jsjs clear select valuejs remove all select from dropdownhow to clear select value in javascriptjs clear selection select dropdownjavascript clear selected optionjavascript reset options in select box to dafaultjs reset selection select dropdownclear selected option jsreset select element javascriptreset a select in javascripthow to reset select dropdown in jqueryhow to clear select options in javascriptjs clear select set valueclear select dropdown javascript clear dropdown selectionjavascript clearing select optionsjs remove all select optionsjavascript clear options from selecthow to clear select dropdown using reset htmljavascript select clear optionsreset select tag jshow to reset dropdown using javascriptjs clear selected optionjavascript reset select valuejs clear options from selectjavascript clear select clear select jsjavascript clear selectionhow to clear a select drop down htmlhow to reset dropdown selected value in javascripthow to clear select in javascripthow to reset select option in javascripthow to clean select value javascriptselect clear options jshow to reset select box value in javascriptjavascript clear all options from selectclear select content javascriptclear all select options javascriptdom clear dropdown optionshow to clear all options from select jsselect box clear jsselect clear javascriptjavascript show field if select option is selected and clear clear select field javascriptreset select option javascriptclear selection javascripthow to clear selection dropdown list in javascriptclear selection of dropsown in javascriptjs how to make a dropdown clear the select when clickedselect clear jsreset select selection in htmljavascript remove all select optionsjs clear elements from selectextjs clear combobox selectionclear select box and table javascriptjavascript remove all options from select drop downhow to reset dropdown selected value in javascript automaticallyclear select in javascriptjavascript function to reset selectmdn select clear selectionallow clear on html select javascriptclear dropdown javascriptclear selected value dropdown javascriptjavascript reset select dropdownreset select option to default jsclear select options javascriptreset select javascriptjs reset selectionjs reset selectclear all options from select javascriptreset dropdown list javascriptclear select dropdown js