Projekt

Obecné

Profil

Stáhnout (1.73 KB) Statistiky
| Větev: | Tag: | Revize:
1
    // Globals
2
    //
3

    
4

    
5
    /*
6
     * Multiple Selection lists in HTML Document
7
     */
8
    var tableColumnList;
9
    var indexColumnList;
10

    
11
    /*
12
     * Two Array vars
13
     */
14

    
15
    var indexColumns, tableColumns;
16

    
17

    
18
    function buttonPressed(object) {
19

    
20
             if (object.name == "add") {
21
                 from = tableColumnList;
22
                 to = indexColumnList;
23
             }
24
             else {
25
                 to = tableColumnList;
26
                 from = indexColumnList;
27
             }
28

    
29
             var selectedOptions = getSelectedOptions(from);
30

    
31
             for (i = 0; i < selectedOptions.length; i++) {
32
                  option = new Option(selectedOptions[i].text);
33
                  addToArray(to, option);
34
                  removeFromArray(from, selectedOptions[i].index);
35
             }
36
    }
37

    
38
    function doSelectAll() {
39
      for(var x = 0; x < indexColumnList.options.length; x++){
40
         indexColumnList.options[x].selected = true;
41
      }
42
    }
43

    
44
    function init() {
45
             tableColumnList = document.formIndex.TableColumnList;
46
             indexColumnList = document.getElementById("IndexColumnList");
47
             indexColumns = indexColumnList.options;
48
             tableColumns = tableColumnList.options;
49
    }
50

    
51

    
52
    function getSelectedOptions(obj) {
53
             var selectedOptions = new Array();
54

    
55
             for (i = 0; i < obj.options.length; i++) {
56
                  if (obj.options[i].selected) {
57
                      selectedOptions.push(obj.options[i]);
58
                  }
59
             }
60

    
61
             return selectedOptions;
62
    }
63

    
64
    function removeFromArray(obj, index) {
65
             obj.remove(index);
66
    }
67

    
68
    function addToArray(obj, item) {
69
             obj.options[obj.options.length] = item;
70
    }
(25-25/53)