<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>

<script language="javascript" >...

function moveOpR()...{
var os=document.getElementById("s");
var os2=document.getElementById("s2");
if(os.options.length>=1)...{
var txt=os.options[os.options.selectedIndex].text;
var val=os.options[os.options.selectedIndex].value;
var op=new Option(txt,val,true,true);
os2.options.add(op);
os.remove(os.options.selectedIndex);
}
}
function moveOpL()...{
var os=document.getElementById("s");
var os2=document.getElementById("s2");
if(os2.options.length>=1)...{
var txt=os2.options[os2.options.selectedIndex].text;
var val=os2.options[os2.options.selectedIndex].value;
var op=new Option(txt,val,true,true);
os.options.add(op);//[os2.options.length]=op;
os2.remove(os2.options.selectedIndex);
}
}
</script>
</head>
<body >
<select name="s" size="4" id="s" ondblclick="moveOpR()" >
<option>1 </option>
<option>2 </option>
<option>3 </option>
<option>4 </option>
<option>5 </option>
<option>6 </option>
</select>
<select name="s2" size="4" id="s2" ondblclick="moveOpL()">
<option>7 </option>
<option>8 </option>
<option>9 </option>
<option>10 </option>
<option>11 </option>
<option>12 </option>
</select>
</body>
</html>
本文介绍了一个简单的HTML页面示例,该示例使用JavaScript实现两个下拉选择框之间的选项转移功能。当用户双击其中一个选择框的选项时,该选项会移动到另一个选择框中,反之亦然。此功能通过JavaScript中的`getElementById`方法和`options`属性来实现。
917

被折叠的 条评论
为什么被折叠?



