-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexes.js
70 lines (53 loc) · 1.8 KB
/
indexes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Globals
//
/*
* Multiple Selection lists in HTML Document
*/
var tableColumnList;
var indexColumnList;
/*
* Two Array vars
*/
var indexColumns, tableColumns;
function buttonPressed(object) {
if (object.name == "add") {
from = tableColumnList;
to = indexColumnList;
}
else {
to = tableColumnList;
from = indexColumnList;
}
var selectedOptions = getSelectedOptions(from);
for (i = 0; i < selectedOptions.length; i++) {
option = new Option(selectedOptions[i].text);
addToArray(to, option);
removeFromArray(from, selectedOptions[i].index);
}
}
function doSelectAll() {
for(var x = 0; x < indexColumnList.options.length; x++){
indexColumnList.options[x].selected = true;
}
}
function init() {
tableColumnList = document.formIndex.TableColumnList;
indexColumnList = document.getElementById("IndexColumnList");
indexColumns = indexColumnList.options;
tableColumns = tableColumnList.options;
}
function getSelectedOptions(obj) {
var selectedOptions = new Array();
for (i = 0; i < obj.options.length; i++) {
if (obj.options[i].selected) {
selectedOptions.push(obj.options[i]);
}
}
return selectedOptions;
}
function removeFromArray(obj, index) {
obj.remove(index);
}
function addToArray(obj, item) {
obj.options[obj.options.length] = item;
}