<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>以上是代码,谢谢!!
解决方案 »
- php 如何将从数据库中取出来的数据写入txt文档中
- 如何用php做一个简单的用户登陆页面(最好不用数据库)
- php中为什么session不能传递参数?我是新手,帮帮忙
- 注册用户时出现“Warning: mysql_num_rows(): supplied argument is not a valid MySQL ...
- 显示和隐藏的问题
- php突然间无法连接sqlsever2000
- 散分,谁要就来拿,那个垃圾mn就别眼红了
- 大文件存储到MySQL数据库的问题?
- 如何把溫文本框去除用php
- 关于在javascript里向dialog窗体(模式对话框)传参数的问题,在线等
- 如何不显示二维数组中重复的值!
- 怎么用PHP赚钱
见 http://www.w3school.com.cn/tags/att_select_multiple.asp