Specific implementation of the source code is as follows:
Two-box page Source:
selected roles: <br/> <select multiple= "multiple" name= "Roleids" size= "" id= "Roleids" > <option value= "1" &G
T Director </option> <option value= "2" > Physician </option><option value= "3" > Nurse </option><option Value= "4" > Front </option><option value= "5" > Office/Office </option> </select> <input type= "button" Value= "<<-Add" onclick= "Moveoptions (document.getElementById (' rolelist '), document.getElementById (' RoleIds ') ), "/> <input type=" button "value=" Removes->> "class=" btn1 "onclick=" moveoptions (' Roleids '), document.getElementById (' rolelist ');/> <br/> alternative roles: <br/> <select multiple= "multiple" Size= "Ten" id= "Rolelist" > <option value= "6" > Engineer 1 </option><option value= "7" > engineer 2 </option& Gt;<option value= "8" > Engineer 3 </option><option value= "9" > Engineer 4 </option><option value= "Ten"
; Engineer 5 </option><option Value= > Engineer 6 </option> </select>
Implementation of the JS code:
function Moveoptions (Osource, Otarget) {while
(Osource.selectedindex >-1) {
var opt = osource.options[ Osource.selectedindex];
Osource.removechild (opt);
var mark = true;
for (var i = 0; i < oTarget.options.length i++) {
if (Opt.value = = otarget.options[i].value) {
mark = false;
}
if (Mark) {
var newopt = document.createelement ("option");
Otarget.appendchild (newopt);
Newopt.value = Opt.value;
Newopt.text = Opt.text;
Newopt.selected = true;
}
}