To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / .svn / pristine / 8d / 8d16ae55d2f1c008a010086c27548d8733c4f49f.svn-base @ 1297:0a574315af3e

History | View | Annotate | Download (1.89 KB)

1
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
2

    
3
function addOption(theSel, theText, theValue)
4
{
5
  var newOpt = new Option(theText, theValue);
6
  var selLength = theSel.length;
7
  theSel.options[selLength] = newOpt;
8
}
9

    
10
function swapOptions(theSel, index1, index2)
11
{
12
	var text, value;
13
  text = theSel.options[index1].text;
14
  value = theSel.options[index1].value;
15
  theSel.options[index1].text = theSel.options[index2].text;
16
  theSel.options[index1].value = theSel.options[index2].value;
17
  theSel.options[index2].text = text;
18
  theSel.options[index2].value = value;
19
}
20

    
21
function deleteOption(theSel, theIndex)
22
{ 
23
  var selLength = theSel.length;
24
  if(selLength>0)
25
  {
26
    theSel.options[theIndex] = null;
27
  }
28
}
29

    
30
function moveOptions(theSelFrom, theSelTo)
31
{
32
  
33
  var selLength = theSelFrom.length;
34
  var selectedText = new Array();
35
  var selectedValues = new Array();
36
  var selectedCount = 0;
37
  
38
  var i;
39
  
40
  for(i=selLength-1; i>=0; i--)
41
  {
42
    if(theSelFrom.options[i].selected)
43
    {
44
      selectedText[selectedCount] = theSelFrom.options[i].text;
45
      selectedValues[selectedCount] = theSelFrom.options[i].value;
46
      deleteOption(theSelFrom, i);
47
      selectedCount++;
48
    }
49
  }
50
  
51
  for(i=selectedCount-1; i>=0; i--)
52
  {
53
    addOption(theSelTo, selectedText[i], selectedValues[i]);
54
  }
55
  
56
  if(NS4) history.go(0);
57
}
58

    
59
function moveOptionUp(theSel) {
60
	var index = theSel.selectedIndex;
61
	if (index > 0) {
62
		swapOptions(theSel, index-1, index);
63
  	theSel.selectedIndex = index-1;
64
	}
65
}
66

    
67
function moveOptionDown(theSel) {
68
	var index = theSel.selectedIndex;
69
	if (index < theSel.length - 1) {
70
		swapOptions(theSel, index, index+1);
71
  	theSel.selectedIndex = index+1;
72
	}
73
}
74

    
75
function selectAllOptions(id)
76
{
77
  var select = $(id);
78
  for (var i=0; i<select.options.length; i++) {
79
    select.options[i].selected = true;
80
  }
81
}
82