一、按"delete"按钮时错误在什么地方。
二、如的表单上设了“确定”按钮后,用什么语句可以取得列表"s2"中的所有内容。谢谢了!
<html >
<script language="JavaScript">
function addnew(){
if(checked_check("s1") != true)
{
alert("Please s1 a option!");
return false;
}
var t=document.all.s1;
var tt=document.all.s2;
var text=t.options[t.selectedIndex].innerText;
var value=t.options[t.selectedIndex].value;
tt.options.add(new Option(text,value));
t.options.remove(t.selectedIndex);
t.selectedIndex = 0;
tt.selectedIndex = 0;
}
function remove(){
if(checked_check("s2") != true)
{
alert("Please s2 a option!");
return false;
}
var t1=document.all.s1;
var t2=document.all.s2;
var text=t2.options[t2.selectedIndex].innerText;
var value=t2.options[t2.selectedIndex].value;
s2.options.remove(t2.selectedIndex);
t1.options.add(new Option(text,value));
s1.selectedIndex = 0;
s2.selectedIndex = 0;
}
function checked_check(idname)
{
var checkobject = document.getElementById(idname);
var coun = checkobject.length;
for(i=0;i<coun;i++)
{
if(checkobject.options[i].selected == true)
return true;
}
return false;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="300" border="0" align="center">
<tr>
<td><label>
<div align="center">
<select id=s1 size=3>
<option value="yw">语文</option>
<option value="sx">数学</option>
<option value="yy">英语</option>
</select>
</div>
</label></td>
<td><div align="center">
<label>
<input type="button" name="Submit" onclick=addnew() value="add" />
<br />
<input type="button" name="Submit2" onclick=remove() value="delete" />
</label>
</div></td>
<td><label>
<div align="center">
<select id=s2 size=3>
</select>
</div>
</label></td>
</tr>
</table>
</form>
</body>
</html>