<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<style>
#left{
float: left;
margin-left: 50px;
}
.assoc_buttons{
margin-left: 20px;
width: 8em;
margin-right: 20px;
vertical-align: middle;
}
#right{
clear: both;
}
</style>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form id="frm" name="frm">
<select name="left" id="left" size="7">
<option value="5">Location C</option>
<option value="8">Location E</option>
</select>
<input type="button" class="assoc_buttons" name="btn_add" value="< Add" onclick="add();"><br>
<input type="button" class="assoc_buttons" name="btn_add_all" value="<< Add All" onclick="add_all();"><br>
<input type="button" class="assoc_buttons" name="btn_del" value="Delete >" onclick="del();"><br>
<input type="button" class="assoc_buttons" name="btn_del_all" value="Delete All >>" onclick="del_all();">
<select name="right" id="right" size="7">
<option value="4">Location A</option>
<option value="6">Location B</option>
<option value="2">Location D</option>
<option value="10">Location F</option>
<option value="1">Location G</option>
<option value="9">Location H</option>
<option value="7">Location I</option>
<option value="3">Location J</option>
</select>
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
#left{
float: left;
margin-left: 50px;
}
.assoc_buttons{
margin-left: 20px;
width: 8em;
margin-right: 20px;
vertical-align: middle;
}
#right{
clear: both;
vertical-align: middle;
}
</style>
</head>
<body>
<form id="frm" name="frm">
<select name="left" id="left" size="7">
<option value="5">Location C</option>
<option value="8">Location E</option>
</select>
<input type="button" class="assoc_buttons" name="btn_add" value="< Add" onclick="add();"><br>
<input type="button" class="assoc_buttons" name="btn_add_all" value="<< Add All" onclick="add_all();"><br>
<input type="button" class="assoc_buttons" name="btn_del" value="Delete >" onclick="del();"><br>
<input type="button" class="assoc_buttons" name="btn_del_all" value="Delete All >>" onclick="del_all();">
<select name="right" id="right" size="7">
<option value="4">Location A</option>
<option value="6">Location B</option>
<option value="2">Location D</option>
<option value="10">Location F</option>
<option value="1">Location G</option>
<option value="9">Location H</option>
<option value="7">Location I</option>
<option value="3">Location J</option>
</select>
</form>
<script type="text/javascript">
function add(){
var from = document.getElementById('right');
var to = document.getElementById('left');
if (from.selectedIndex == -1){
alert ("No Locations were selected to be added.");
return false;
}
var selectedOption =
}
</script>
</body>
</html>
<script type="text/javascript">
function add(){
var from = document.getElementById('right');
var to = document.getElementById('left');
if (from.selectedIndex == -1){
alert ("No Locations were selected to be added.");
return false;
}
var i = from.selectedIndex;
var newVal = from.options[i].value;
var newText = from.options[i].text;
//Remove from item
from.options.remove[i];
//Add to item
to.options[to.options.length] = new Option(newText, newVal);
}
</script>
<!DOCTYPE html>
<html><head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.tbl1 {
margin-left: 50px;
border: 1px solid #a33;
}
</style>
<script>
var rSel=false, lSel=false;
function id2obj(elmt1){return document.getElementById(elmt1);}
function moveOne(sel){
var del = rSel;
if (sel) {
sel = lSel;
} else {
sel = rSel;
del = lSel;
}
var si = del.selectedIndex;
if (si == -1){
if (del == rSel) sel = "RIGHT"; else sel = "LEFT";
alert ("No Locations on "+sel+" were selected to be moved.");
return;
}
//alert ("selet= "+del.options[si].value+" - "+del.options[si].text);
var opt = document.createElement('option');
opt.value = del.options[si].value;
opt.innerHTML = del.options[si].text;
sel.appendChild(opt);
del.removeChild(del.options[si]);
}
</script>
</head>
<body>
<form id="frm" name="frm">
<table class="tbl1"><tr><td>
<select name="left" id="leftSel" size="7">
<option value="5">Location C</option>
<option value="8">Location E</option>
</select>
</td><td style="text-align:center;">
<input type="button" name="btn_add" value="< Add" onclick="moveOne(1)"><br />
<input type="button" name="btn_add_all" value="<< Add All" onclick="add_all();"><br />
<input type="button" name="btn_del" value="Delete >" onclick="moveOne(0);"><br />
<input type="button" name="btn_del_all" value="Delete All >>" onclick="del_all();">
</td><td>
<select name="right" id="rightSel" size="7">
<option value="4">Location A</option>
<option value="6">Location B</option>
<option value="2">Location D</option>
<option value="10">Location F</option>
<option value="1">Location G</option>
<option value="9">Location H</option>
<option value="7">Location I</option>
<option value="3">Location J</option>
</select>
</td></tr></table>
</form>
<script>
var rSel = id2obj('rightSel');
var lSel = id2obj('leftSel');
</script>
</body>
</html>
function moveAll(sel){
var del = rSel;
if (sel) {
sel = lSel;
} else {
sel = rSel;
del = lSel;
}
if (del.options.length < 1) {
alert ("The Box is Empty, nothing to move.");
return;
}
var aryOp = [];
for (var i= del.options.length-1; i > -1 ; --i) {
var al = aryOp.length;
aryOp[al] = document.createElement('option');
aryOp[al].value = del.options[i].value;
aryOp[al].innerHTML = del.options[i].text;
del.removeChild(del.options[i]);
}
for (i= aryOp.length-1; i > -1 ; --i) {
sel.appendChild(aryOp[i]);
}
}