在JavaScript中给select下拉框赋值的方法有以下几种:
var select = document.getElementById("mySelect");
select.innerHTML = "<option value='1'>Option 1</option><option value='2'>Option 2</option>";
var select = document.getElementById("mySelect");
var option1 = document.createElement("option");
option1.value = "1";
option1.text = "Option 1";
select.appendChild(option1);
var option2 = document.createElement("option");
option2.value = "2";
option2.text = "Option 2";
select.appendChild(option2);
var select = document.getElementById("mySelect");
var option1 = new Option("Option 1", "1");
var option2 = new Option("Option 2", "2");
select.add(option1);
select.add(option2);
var select = document.getElementById("mySelect");
select.options[0] = new Option("Option 1", "1");
select.options[1] = new Option("Option 2", "2");
以上是几种常见的给select下拉框赋值的方法,可以根据具体需求选择合适的方法。