欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于JavaScript實(shí)現(xiàn)下拉列表左右移動(dòng)代碼

 更新時(shí)間:2017年02月07日 16:29:43   作者:孫瑞  
這篇文章主要介紹了基于JavaScript實(shí)現(xiàn)下拉列表左右移動(dòng)效果,代碼簡(jiǎn)單易懂非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下

廢話不多說(shuō),先給大家展示一下效果圖,如果大家感覺不錯(cuò),請(qǐng)參考實(shí)現(xiàn)代碼。

效果圖如下所示:

代碼如下所示:

<!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=utf-8" /> 
<title>選擇式下拉菜單</title> 
<script language="javascript" type="text/javascript">  
  function moveOption(e1, e2){  
    try{  
      for(var i=0;i<e1.options.length;i++){  
        if(e1.options[i].selected){  
          var e = e1.options[i];  
          e2.options.add(new Option(e.text, e.value));  
          e1.remove(i);  
          ii=i-1; 
        }  
      }  
      document.form1.city.value=getvalue(document.form1.list2);  
    }catch(e){ 
     }  
  }  
   function getvalue(geto){  
    var allvalue = "";  
    for(var i=0;i<geto.options.length;i++){  
      allvalue +=geto.options[i].value + ",";  
    }  
    return allvalue;  
  } 
   function changepos(obj,index)  
  {  
    if(index==-1){  
      if (obj.selectedIndex>0){  
        //obj.options(obj.selectedIndex).swapNode(obj.options(obj.selectedIndex-1)) //swapNode方法只有IE才支持 
        obj.insertBefore(obj.options[obj.selectedIndex], obj.options[obj.selectedIndex - 1]);  
      }  
    }else if(index==1){  
      if (obj.selectedIndex<obj.options.length-1){  
        //obj.options(obj.selectedIndex).swapNode(obj.options(obj.selectedIndex+1)) //swapNode方法只有IE才支持 
        obj.insertBefore(obj.options[obj.selectedIndex + 1], obj.options[obj.selectedIndex]);   
      }  
    }  
  }  
</script> 
<style type="text/css"> 
body { 
  font-size: 16px; 
  color: #003300; 
} 
</style> 
</head> 
<body> 
<form method="post" name="form1" action="" style="text-align:center;"> 
 <table border="0" width="300" align="center"> 
  <tr> 
   <td width="40%"><select style="width:100%" multiple name="list1" size="12" ondblclick="moveOption(document.form1.list1, document.form1.list2)"> 
     <option value="張三">張三</option> 
     <option value="李四">李四</option> 
     <option value="王五">王五</option> 
     <option value="趙六">趙六</option> 
     <option value="錢七">錢七</option> 
     <option value="軟件">軟件</option> 
     <option value="客服">客服</option> 
     <option value="硬件">硬件</option> 
     <option value="安全">安全</option> 
     <option value="會(huì)計(jì)">會(huì)計(jì)</option> 
     <option value="出納">出納</option> 
    </select></td> 
   <td width="20%" align="center"><input type="button" value="添加" onclick="moveOption(document.form1.list1, document.form1.list2)"/> 
    <br/> 
    <br/> 
    <input type="button" value="刪除" onclick="moveOption(document.form1.list2, document.form1.list1)"/></td> 
   <td width="40%"><select style="width:100%" multiple name="list2" size="12" ondblclick="moveOption(document.form1.list2, document.form1.list1)"> 
    </select></td> 
   <td><input type="button" value="上移" onclick="changepos(list2,-1)"/> 
    <br/> 
    <br/> 
    <input type="button" value="下移" onclick="changepos(list2,1)"/></td> 
  </tr> 
 </table> 
 值: 
 <input type="text" name="city" size="40" /> 
</form> 
<p align="center">選定一項(xiàng)或多項(xiàng)然后點(diǎn)擊添加或移除(按住shift或ctrl可以多選),<br /> 
 或在選擇項(xiàng)上雙擊進(jìn)行添加和移除。</p> 
</body> 
</html> 

以上所述是小編給大家介紹的基于JavaScript實(shí)現(xiàn)下拉列表左右移動(dòng),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • js轉(zhuǎn)換對(duì)象為xml

    js轉(zhuǎn)換對(duì)象為xml

    本文主要介紹了js轉(zhuǎn)換對(duì)象為xml的方法。具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧
    2017-02-02
  • JavaScript提取元素中第一個(gè)子元素的實(shí)現(xiàn)方法

    JavaScript提取元素中第一個(gè)子元素的實(shí)現(xiàn)方法

    本文主要介紹了JavaScript提取元素中第一個(gè)子元素的實(shí)現(xiàn)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-06-06
  • setTimeout時(shí)間設(shè)置為0詳細(xì)解析

    setTimeout時(shí)間設(shè)置為0詳細(xì)解析

    setTimeout( ) 是屬于 window 的 method, 但我們都是略去 window 這頂層容器名稱, 這是用來(lái)設(shè)定一個(gè)時(shí)間, 時(shí)間到了, 就會(huì)執(zhí)行一個(gè)指定的 method,下面這篇文章主要給大家介紹了關(guān)于setTimeout時(shí)間設(shè)置為0的相關(guān)資料,需要的朋友可以參考下。
    2018-03-03
  • TinyMCE提交AjaxForm獲取不到數(shù)據(jù)的解決方法

    TinyMCE提交AjaxForm獲取不到數(shù)據(jù)的解決方法

    這篇文章主要介紹了TinyMCE提交AjaxForm獲取不到數(shù)據(jù)的解決方法,實(shí)例分析了對(duì)應(yīng)的源碼部分與相應(yīng)的解決方法,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-03-03
  • ES6中Set和Map數(shù)據(jù)結(jié)構(gòu),Map與其它數(shù)據(jù)結(jié)構(gòu)互相轉(zhuǎn)換操作實(shí)例詳解

    ES6中Set和Map數(shù)據(jù)結(jié)構(gòu),Map與其它數(shù)據(jù)結(jié)構(gòu)互相轉(zhuǎn)換操作實(shí)例詳解

    這篇文章主要介紹了ES6中Set和Map數(shù)據(jù)結(jié)構(gòu),Map與其它數(shù)據(jù)結(jié)構(gòu)互相轉(zhuǎn)換操作,結(jié)合實(shí)例形式詳細(xì)分析了ES6中的Set和Map數(shù)據(jù)結(jié)構(gòu)的概念、原理、遍歷、去重等操作,以及Map與其它數(shù)據(jù)結(jié)構(gòu)互相轉(zhuǎn)換操作,需要的朋友可以參考下
    2019-02-02
  • 微信小程序?qū)崿F(xiàn)自動(dòng)回復(fù)圖片消息

    微信小程序?qū)崿F(xiàn)自動(dòng)回復(fù)圖片消息

    這篇文章主要介紹了微信小程序?qū)崿F(xiàn)客服消息自動(dòng)回復(fù)圖片消息,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧
    2023-01-01
  • layer.msg()去掉默認(rèn)時(shí)間,實(shí)現(xiàn)手動(dòng)關(guān)閉的方法

    layer.msg()去掉默認(rèn)時(shí)間,實(shí)現(xiàn)手動(dòng)關(guān)閉的方法

    今天小編就為大家分享一篇layer.msg()去掉默認(rèn)時(shí)間,實(shí)現(xiàn)手動(dòng)關(guān)閉的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-09-09
  • javascript寫的日歷類(基于pj)

    javascript寫的日歷類(基于pj)

    在網(wǎng)上搜索了一些用javascript寫的日歷類都不太令人滿意,主要是用了之后還要寫很多客戶端代碼,有空之余,自己動(dòng)手寫了一個(gè)。主要是推廣自己寫的js pr庫(kù)。
    2010-12-12
  • 三種檢測(cè)iPhone/iPad設(shè)備方向的方法

    三種檢測(cè)iPhone/iPad設(shè)備方向的方法

    這篇文章主要介紹了檢測(cè)iPhone/iPad設(shè)備方向的三種方法,需要的朋友可以參考下
    2014-04-04
  • php基于redis處理session的方法

    php基于redis處理session的方法

    這篇文章主要介紹了php基于redis處理session的方法的相關(guān)資料,需要的朋友可以參考下
    2016-03-03

最新評(píng)論