请教在JavaScript中的下拉菜单怎样显示
我在网页里面想实现动态增加和减少一行,现在可以实现了,可是我在增加的过程中 在一行中有下拉菜单,下拉菜单中的内容不显示,都是空白的,谁帮帮忙看看要怎么做吧,谢谢啦!!!下面是我的代码
程序代码:
<script language="javascript"> function add(){ //取得表格 var table = document.getElementById("table1"); //取得行数; var num = table.rows.length; //增加一行 var newrow1 = table.insertRow(num-1); var cell1 = newrow1.insertCell(); var cell2 = newrow1.insertCell(); var cell3 = newrow1.insertCell(); var cell4 = newrow1.insertCell(); var cell5 = newrow1.insertCell(); var cell6 = newrow1.insertCell(); var cell7 = newrow1.insertCell(); cell1.align="center"; cell2.align="center"; cell3.align="center"; cell4.align="center"; cell5.align="center"; cell6.align="center"; cell7.align="center"; //增加行元素 var inputcell3 = document.createElement("<input maxLength=6 type=text name='' size=8>"); cell3.appendChild(inputcell3); var inputcell4 = document.createElement("<textarea name='' rows=3 cols=14 >"); cell4.appendChild(inputcell4); var inputcell5 = document.createElement("<textarea name='' rows=3 cols=14 >"); cell5.appendChild(inputcell5); var inputcell6 = document.createElement("<select name='' style='width=120'><option value=''></option><option value='OK'>OK</option><option value='NG'>NG</option><option value='Other'>Other</option></select>"); cell6.appendChild(inputcell6); var inputcell7 = document.createElement("<textarea name='' rows=3 cols=14 ></textarea>"); cell7.appendChild(inputcell7); //刷新标签显示 frash(); } function del(obj){ //取得按钮所在行 var i = obj.parentNode.parentNode.rowIndex; var tab = document.getElementById("table1"); //删除按钮所在行 var num = tab.rows.length; alert(num); if(num==3){ alert("不能全部删除,请保留至少一条!"); return false; ; } tab.deleteRow(i); frash(); } function frash(){ var table = document.getElementById("table1"); var num = table.rows.length; //计算动态元素个数 var n = num-2; for(i=1;i<=n;i++){ //设置标签值 table.rows[i].cells[0].innerHTML="<img border='0' src=/ICO_Delete.gif onClick='del(this);' style='cursor:hand'>"; //设置属性值 table.rows[i].cells[1].innerText=""+i+""; table.rows[i].cells[2].childNodes[0].setAttribute("name","id"+i); table.rows[i].cells[3].childNodes[0].setAttribute("name","reason"+i); table.rows[i].cells[4].childNodes[0].setAttribute("name","remark"+i); table.rows[i].cells[5].childNodes[0].setAttribute("name","status"+i); table.rows[i].cells[6].childNodes[0].setAttribute("name","op"+i); } } </script>