The ListBox implements a simple example of moving up, down, moving left, and moving right

Source: Internet
Author: User

  This article mainly introduces a simple example of how to move up, down, move left, and move right in the listbox implementation. Need friends can come to the reference, I hope to help you.

    Code as follows: <html> <head>     <title>javascript version select Pull-down menu to move and sort </title>   & nbsp <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 > </head> <body>     <p> Select one or more items and then click Add or Remove (hold down SHIFT or CTRL to select more). or double-click on the selection to add and remove. </p>     <form method= "POST" name= "MyForm" >     <table border= "0" width= "" > &nbs P       <tr>             <TD width= "40%" >       &NBS P         <select style= "width:100px; height:200px "Multiple name=" List1 "size=" "ondblclick=" Moveoption (Document.myform.list1, Document.myform.list2) " >                     <option value= "Beijing" > Beijing </option> &nbs P                   <option value= "Shanghai" > Shanghai </option>     &N Bsp       &NBSP       <option value= "Shandong" > Shandong </option>                 &N Bsp   <option value= "Anhui" > Anhui </option>                     &L T;option value= "Chongqing" > Chongqing </option>                     <option Value= "Fujian" > Fujian </option>                     <option value= "Gansu "> Gansu </option>                     <option value=" Guangdong "> Guangdong &L t;/option>                     <option value= "Guangxi" > Guangxi </option >                     <option value= "Guizhou" > Guizhou </option> &nbs P                   <option value= "Hainan" > Hainan </option>     &N Bsp   &nbsp           <option value= "Hebei" > Hebei </option>             &N Bsp       <option value= "Heilongjiang" > Heilongjiang </option>                     <option value= "Henan" > Henan </option>                   &N Bsp <option value= "Hubei" > Hubei </option>                     <optio n value= "Hunan" > Hunan </option>                     <option value= " Inner Mongolia "> Inner Mongolia </option>                     <option value=" Jiangsu "> Jiangsu </option>                     <option value= "Jiangxi" > Jiangxi </op tion>                     <option value= "Jilin" > Jilin </option>   &nbsp                 <option value= "Liaoning" > Liaoning </option>       &N Bsp             <option value= "Ningxia" > Ningxia </option>           &N Bsp         <option value= "Qinghai" > Qinghai </option>               &N Bsp     <option value= "Shanxi" > Shanxi </option>                   &N Bsp <option value= "Shaanxi" > Shaanxi </option>                     <optio n value= "Sichuan" > Sichuan </option>                     <option value= " Tianjin "> Tianjin </option>                     <option value=" Tibet "> Tibet </option>                     <option value= "Xinjiang" > Xinjiang </option>                     <option value= "Yunnan" > Yunnan </option>                     <option value= "Zhejiang" > Zhejiang </option>   &N Bsp                 <option value= "Hong Kong" > Hong Kong </option>       &N Bsp             <option value= "Macau" > Macau </option>           &N Bsp         <option value= "Taiwan" > Taiwan </option>               &N Bsp     <option value= "Other" > Other </option>                 </sele ct>             </td>             <TD width= "20%" align= "center" >                 <input type= "button" value= ">>" onclic K= "MOveoption (Document.myform.list1, document.myform.list2) "><br/>                 <br/>                 <input type= "button" value= "<< "Onclick=" Moveoption (Document.myform.list2, Document.myform.list1) ">             < /TD>             <TD width= "40%" >                 <select style= "width:100px; height:200px "Multiple name=" List2 "size=" "ondblclick=" Moveoption (Document.myform.list2, Document.myform.list1) " >                 </select>             ;/td>             <td>                 < Button onclick= "Changepos (list2,-1)" type= "button" >                   &NBS P∧</button>                 <br/>           & nbsp     <button onclick= "Changepos (list2,1)" type= "button" >               & nbsp    ∨</button>             </td>         </TR&G T     </table>     value: <input type= "text" name= "City" size= "" ">     </form> nbsp   <script language= "JavaScript" >      <!--        function moveoption (E 1, E2) {            try {                for (var i = 0; i < e1.options.length; i++) {                    if (e1.options[i].selected) {    & nbsp                   var e = e1.options[i]; &nbsp                       E2.options.add (new Option (E.text, E.value));                         e1.remove (i);                         i = i-1                                                     Document.myform.city.value = GetValue (DOCUMENT.MYFORM.LIST2);                         catch (e) {}       & nbsp }           function GetValue (geto) {            var allvalue = "" ;             for (var i = 0; i < geto.options.length i++) {        & nbsp       Allvalue + + Geto.options[i].valUE + ",";                         return allvalue;        }           function changepos (obj, index) {      &NB Sp     if (index = 1) {                if (Obj.selectedindex > 0) {& nbsp                   obj.options (obj.selectedindex) SwapNode (Obj.options ( obj.selectedindex-1)                 {          &NBSP ; }             ELSE if (index = 1) {                if (Obj.selectedindex < obj.options.length-1) {                  &NBSP ; Obj.options (Obj.selectedindex). SwapNode (Obj.options (Obj.selectedindex + 1))             & nbsp  }           }        }     //-->      </SCRIPT&G T </body> </html>  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.