就是:比如说:这段代码:<html>
<head>
</head>
<body>
<table id="flowtable" width=100%>
<tr>
<td>
<input type=button value="click me" onclick="change()">
</td>
</tr>
</table>
</body>
</html>
<script>
var j=0
function change(){
j=2;
newRow=document.all.flowtable.insertRow(-1);
newcell=newRow.insertCell(); newcell.innerHTML=j;
newcell=newRow.insertCell();newcell.innerHTML="<select name=\"select\"><option value=1>1</option><option value=2>2</option></select>";
newcell=newRow.insertCell();
alert(flowtable.innerHTML);
}
</script>其中select中的option的数量是动态的,当select的length为0时,提示出错并返回,怎么写呢?
<head>
</head>
<body>
<table id="flowtable" width=100%>
<tr>
<td>
<input type=button value="click me" onclick="change()">
</td>
</tr>
</table>
</body>
</html>
<script>
var j=0
function change(){
j=2;
newRow=document.all.flowtable.insertRow(-1);
newcell=newRow.insertCell(); newcell.innerHTML=j;
newcell=newRow.insertCell();newcell.innerHTML="<select name=\"select\"><option value=1>1</option><option value=2>2</option></select>";
newcell=newRow.insertCell();
alert(flowtable.innerHTML);
}
</script>其中select中的option的数量是动态的,当select的length为0时,提示出错并返回,怎么写呢?
<head>
</head>
<body>
<div id="bao"></div>
<tr>
<td>
<input type=button value="click me" onclick="check()">
</td>
</tr>
</table>
</body>
</html>
<script>
bao.innerHTML="<select id=\"sel1\"><option value=1>1</option><option value=2>2</option></select>";
function check()
{
sel = document.getElementById("sel1");
alert(sel.options.length);
}
</script>