在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下拉框賦值的方法,可以根據具體需求選擇合適的方法。