var jsonurl = "${ctx}/jsonrpc";
var jsonrpc = null;
var unitDropDown = document.getElementById("equipmentName");
function filterUnits(plantDropDown) {
var plantName = plantDropDown.options[plantDropDown.selectedIndex].value;
if (plantName == "") {
reloadUnits("");
return;
}
try {
jsonrpc = new JSONRpcClient(jsonurl);
} catch(e) {
alert(e);
}
// Call a Java method on the server
var units = jsonrpc.lookupHelper.getUnitsForPlant(plantName);
setUnits(units);
}
function reloadUnits(value) {
if (value == "") {
try {
jsonrpc = new JSONRpcClient(jsonurl);
} catch(e) {
alert(e);
}
// Call a Java method on the server
var units = jsonrpc.lookupHelper.getAllUnits();
setUnits(units);
}
}
function setUnits(units) {
var unitArray = units.split(",");
unitDropDown.options.length = 1; // keep "All" option
for (i=0; i < unitArray.length; i++) {
unitDropDown.options[unitDropDown.options.length] =
new Option(unitArray[i], unitArray[i]);
}
}