jsがdomを操作してプルダウンリストボックスを生成する方法
1037 ワード
dom
<br>function setFun(){
<br>var id = new Array(1,2,3);
<br>var value = new Array(" "," "," ");
<br>var select = document.getElementById("area");
<br>select.length = 1;//
<br>select.options[0].selected = true;//
<br>for(var x = 0;x<id.length;x++){
<br>var option = document.createElement("option");
<br>option.setAttribute("value",id[x]);// option
<br>option.appendChild(document.createTextNode(value[x]));
<br>select.appendChild(option);// select option
<br>}
<br>}
<br>