Enables the selection of the left and right two listbox
The code is as follows:
1 functionListbox_move (Listfrom, listto) {2 varSize = $j ("#" + listfrom + "option"). Size ();3 varSelsize = $j ("#" + Listfrom + "option:selected"). Size ();4 varstrvalue = "";5 if(Size > 0 && selsize > 0) {6$j. Each ($j ("#" + Listfrom + "option:selected"),function(I, own) {7 varStext =$j (Own). text ();8 varsvalue =$j (Own). Val ();9 varFlag =true;Ten$j. Each ($j ("#" + listto + "option"),function(ID, ownto) { One if($j (Ownto). val () = =svalue) { AFlag =false; - } - }); the if(flag) { -$j ("#" + Listto). Append ("<option value=\" "+ svalue +" \ ">" + stext + "</option>"); -strvalue + = $j (Own). Text () + ":" +$j (Own). Val (); -strvalue + = ","; + } - $j (Own). Remove (); +$j ("#" + Listfrom + ""). Children ("Option:first"). attr ("Selected",true); A }); at}Else { - if(listfrom== ' Listbcos ') { -Alert (' Please select the information you want to import first! ‘); -}Else { -Alert (' Please select the information you want to delete first! ‘); - } in } -}
Interface elements:
1 <TDwidth= "28%">2 <inputID= "Txtcos"type= "text"width= "100%" />3 <SelectID= "Listbcos"multiple= "multiple"style= "width:200px; height:130px;"></Select>4 </TD>5 <TDAlign= "Center"width= "12%"><BR/> <BR/> <BR/>6 <inputtype= "button"ID= "Btnimport"value= "Import >>"style= "cursor:p ointer"onclick= "Listbox_move (' Listbcos ', ' listbcontent ')"/><BR/><BR/>7 <inputtype= "button"ID= "Btndel"value= "<< Delete"style= "cursor:p ointer"onclick= "Listbox_move (' listbcontent ', ' Listbcos ')"/><BR/> <BR/><BR/>8 </TD>9 <TDwidth= "28%">Ten <SelectID= "Listbcontent"multiple= "multiple"style= "width:200px; height:150px;"></Select> One </TD>
jquery operation ListBox left and right select each other