是否可以从javascript重新创建select?

是否可以从javascript重新创建select?,javascript,html,Javascript,Html,我正试图从Javascript中更改现有select的值,在internet中查找一段时间后,我不确定这是否可行 我有一段代码: function clickPic(pic_select, choosen, opt){ //Here I change the border of a selected image if (opt!=0){ pic_select.style.border = "3px solid blue"; }else{pic_select.sty

我正试图从Javascript中更改现有select的值,在internet中查找一段时间后,我不确定这是否可行

我有一段代码:

function clickPic(pic_select, choosen, opt){
    //Here I change the border of a selected image
    if (opt!=0){
    pic_select.style.border = "3px solid blue";
    }else{pic_select.style.border = "3px solid red";}
    // here I send the variable (it's a number) which I want to change the values of the select.
    var option_master = opt; 
    cambiarSelect(option_master);   
}

    function cambiarSelect(num){
       //here num is 4 or 6 or 12, depending
       //this is the select itself
        var people = document.getElementById('people');
       //I guess here I reset the select
        people.options.length=0;

        for(var i=1;i<=num.length;i++){
            //here I want to change the values of the select with the same number than num, because thats the value I'm interested to select later
            people.options[i]=new Option(i);
        }
    }
功能点击pic(pic\u选择、选择、选择){
//在这里,我更改选定图像的边框
如果(选项!=0){
pic_select.style.border=“3px纯蓝色”;
}else{pic_select.style.border=“3px实心红色”;}
//在这里,我发送了一个变量(它是一个数字),我想更改select的值。
var option_master=opt;
cambiarSelect(主选项);
}
函数选择(num){
//这里的num是4、6或12,具体取决于
//这是选择本身
var people=document.getElementById('people');
//我想我在这里重置了选择
people.options.length=0;
对于(var i=1;i
函数选择(num){
//这里的num是4、6或12,具体取决于
//这是选择本身
var people=document.getElementById('people');
//我想我在这里重置了选择
people.innerHTML='';//清除您的选择
对于(var j=1;j
函数选择(num){
//这里的num是4、6或12,具体取决于
//这是选择本身
var people=document.getElementById('people');
//我想我在这里重置了选择
people.innerHTML='';//清除您的选择

对于(var j=1;j你能做到。只要用字符串创建元素,然后使用innerHTMLYou就能做到。只要用字符串创建元素,然后使用innerHTMLEle!你是一个机器人!!解决了!!我看到你的代码时就知道了,我很久没有编程了。Ele!你是一个机器人!!解决了!!我看到你的代码时就知道了,我很久没有编程了。