/includes/js/ -> tablemanage.js
1 // dynamically alters selection list. Found somewhere on the web, altered
2 function fillSelectFromArray(selectCtrl, itemArray) {
3 var i, j;
4 var prompt;
5
6 // remember what was selected
7 //selectedID = selectCtrl.selectedIndex;
8 selectedID = 0;
9 // selectedText = selectCtrl.options[selectedID];
10 selectedText = "";
11 // empty existing items
12 for (i = selectCtrl.options.length; i >= 0; i--) {
13 selectCtrl.options[i] = null;
14 }
15
16 j = 0;
17
18 if (itemArray != null) {
19 // add new items
20 for (i = 0; i < itemArray.length; i++) {
21 selectCtrl.options[j] = new Option(itemArray[i][0]);
22 if (itemArray[i][1] != null) {
23 selectCtrl.options[j].value = itemArray[i][1];
24 if (selectCtrl.options[j].text == selectedText)
25 selectCtrl.options[j].selected = true;
26 selected = true;
27 }
28 j++;
29 }
30 // if nothing selected, select first item
31 if (selected != true)
32 selectCtrl.options[0].selected = true;
33 }
34 }