<script type="text/javascript">
function createoptions(){
sel1 = document.form1.select1 ;
sel2 = document.form1.select2 ;
var num = sel1.selectedIndex ;
if(num >= 0){
var option = new Option(sel1.options[num].text);
var item = sel2.options.length ;
sel2.options[item] = option ;
}
sel1.selectedIndex = 10000 ;
}
function deloptions(){
var sele2 = document.form1.select2 ;
var num = sele2.selectedIndex ;
if(num >= 0){
sele2.options[num] = null ;
}else{
sele2.selectedIndex = 10000 ;
}
}
</script>
<form name="form1" method="post" action="checkbox.php">
<select name="select1" size="10">
<option value="香蕉">香蕉</option>
<option value="苹果">苹果</option>
<option value="葡萄">葡萄</option>
<option value="梨子">梨子</option>
</select>
<input type="button" value="选择" onclick="createoptions()">
<select name="select2" size="10">
<input type="button" value="删除" onclick="deloptions()">
</select>
</form>以上是代码,谢谢!!
function createoptions(){
sel1 = document.form1.select1 ;
sel2 = document.form1.select2 ;
var num = sel1.selectedIndex ;
if(num >= 0){
var option = new Option(sel1.options[num].text);
var item = sel2.options.length ;
sel2.options[item] = option ;
}
sel1.selectedIndex = 10000 ;
}
function deloptions(){
var sele2 = document.form1.select2 ;
var num = sele2.selectedIndex ;
if(num >= 0){
sele2.options[num] = null ;
}else{
sele2.selectedIndex = 10000 ;
}
}
</script>
<form name="form1" method="post" action="checkbox.php">
<select name="select1" size="10">
<option value="香蕉">香蕉</option>
<option value="苹果">苹果</option>
<option value="葡萄">葡萄</option>
<option value="梨子">梨子</option>
</select>
<input type="button" value="选择" onclick="createoptions()">
<select name="select2" size="10">
<input type="button" value="删除" onclick="deloptions()">
</select>
</form>以上是代码,谢谢!!
见 http://www.w3school.com.cn/tags/att_select_multiple.asp