Two select multiple-selection mode options move to each other

Source: Internet
Author: User
Tags eval

  This article is mainly about the two select multiple selection mode of the option to move the sample code for each other, the need for friends can come to the reference, I hope to help you.

As follows:     code is as follows: <! 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> Untitled document </title> <script type=" Text/javascript "> Function copytolist (from , to) {      var fromlist=eval (' document.forms[0]. ' +from);     var tolist=eval (' document.forms[0]. ' +TO);       if (toList.options.length > 0 && tolist.options[0].value = ' temp ') {      & nbsp     tolist.options.length=0;    }       var sel=false;       for (i = 0;i < fromlist.options.length;i++) {        var current=fromlist.optio Ns[i];         if (current.selected) {            sel=true;             if (current.value== ' temp ') {                alert (' Can't select this item! ');   &NBSP ;             return;                         Txt=current.text;             Val=current.value;             tolist.options[tolist.length]=new Option (txt,val);             fromlist.options[i]=null;             i--;        }    /      if (!sel) alert (' You haven't selected any items yet! ') }   function Allselect () {        var Chsen=document.getelementbyid (' Chosen ');    //IF Chsen list box is 0 or the first option value is ' temp '     if (chsen.length && chsen.options[0].value== "temp")         return;       for (Var i=0;i<chsen.length;i++) {            Chsen.options[i].selected=true;    }  //Get Data  function GetData () {          var List = document.for Ms[0].        Rolelist; Get a hidden text box object             var roles = document.getElementById ("Trolelist");             roles.value = "";             var s = "";             if (list.length!= 0) {                for (i = 0; i < list.length i++) {                    S + + list.opt Ions[i].value + ",";                            }               Roles.value = s;        }} </script> </head> <body> <table border= "0" > <form onsubmit= "All Select () ">    <tr>  &NBsp <td>    <select name= "Possible" size= "4" Multiple width= "" style= "width:200px" >    & Lt;option value= "1" > China guangzhou </option> <option value= "2" > China Shanghai </option> <option value= "3" > China Beijing </option>    <option value= "4" > China Wuhan </option>  </select>    </td >    <td><a href= "javascript:copytolist (' possible ', ' chosen ')" > Add to Right--><br>    <br> </a><a href= "javascript:copytolist (' chosen ', ' possible ')" ><--add to left </a ></td>    <td>    <select name= "Chosen"   size= "4" multiple  width= "200 " style=" width:200px; >    <option value= "Temp" > select your area from the left </option>  </select>    </td>    </tr> </form>    </table> <input type= "button"  value= "Submit"   Onclick= "Allselect ()"/>yle <input type= "TeXT "Style=" Display:none; "id=" trolelist "> </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.