Answers for "reset select dropdown javascript"

0

clear select dropdown js

var courses = document.getElementById("special_selection");

    // clear select
    var length = courses.options.length;
    for (i = length - 1; i >= 0; i--) {
      courses.options[i] = null;
    }
    for (var i = 0; i < data.length; i++) {
      var option = document.createElement("OPTION"),
          txt = document.createTextNode(data[i].coursetitle);
      option.appendChild(txt);
      option.setAttribute("value", data[i].KF);
      courses.insertBefore(option, courses.lastChild);

    }
Posted by: Guest on June-25-2021
0

reset select js

$('#id').val('1');
$('#id').trigger('change');
Posted by: Guest on August-27-2021
0

reset select dropdown javascript

var courses = document.getElementById("special_selection");

    // clear select
    var length = courses.options.length;
    for (i = length - 1; i >= 0; i--) {
      courses.options[i] = null;
    }
    for (var i = 0; i < data.length; i++) {
      var option = document.createElement("OPTION"),
          txt = document.createTextNode(data[i].coursetitle);
      option.appendChild(txt);
      option.setAttribute("value", data[i].KF);
      courses.insertBefore(option, courses.lastChild);

    }
Posted by: Guest on July-23-2021

Code answers related to "reset select dropdown javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language