Web双向选择器 左右选择DEMO

<!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>Web双向选择器</title>

<script type="text/javascript" language="javascript">
   function moveItem(dest, source)
   {
        var dest   = ( typeof dest == "string" ? document.getElementById(dest): dest );
        var source = ( typeof source  == "string" ? document.getElementById(source) : source );

        if( source.tagName.toLowerCase() != "select" || dest.tagName.toLowerCase() != "select" )
            return;

        for ( index=source.length - 1; index >= 0; index-- ) {
            if ( source[index].selected ) {
                dest.length++;                    
                dest[dest.length-1].id    = source[index].id;
                dest[dest.length-1].value = source[index].value;
                dest[dest.length-1].text  = source[index].text;
                source[index] = null;
            }
        }
    }
</script>

<style type="text/css">

select
{}{
    margin:-2px;
}
</style>
</head>
<body>
    <table width="20%" border="1" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td width="10%">        
                <select size="10" multiple="multiple" id="left" οndblclick="moveItem(right,this)" style="width:120px; ">
                    <option value="def7">ListItem1</option>
                    <option value="abcd6">ListItem2</option>
                </select>
            </td>
            <td width="3%">
                <input type="button" value=" >> " name="btnRight" οnclick="moveItem(right,left)" />              
                <input type="button" value=" << " οnclick="moveItem(left,right)" id="btn" name="btnLeft" />
            </td>
            <td width="10%">
        
                <select size="10" multiple="multiple" id="right" οndblclick="moveItem(left,this)" style="width:120px; ">
                    <option value="abce">ListItemm3</option>
                    <option value="def1">ListItem4</option>
                    <option value="abcd2">ListItem5</option>
                    <option value="abc3">ListItem6</option>
                    <option value="def4">ListItem7</option>
                    <option value="abcd5">ListItem8</option>
                </select>
            </td>
        </tr>
    </table>
</body>
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值