function addOption(list, name, value) { var option = document.createElement('option'); option.appendChild(document.createTextNode(name)); option.value = value; list.appendChild(option); } function clearOptions(list) { while (list.childNodes.length) list.removeChild(list.firstChild); list.selectedIndex = -1; } function selectTopDataCat_onchange() { var xsrc = document.getElementById("selectTopCatDept"); clearOptions(xsrc); var xURI = "topCatDept.asp?catCode=" + document.getElementById("selectTopDataCat").value; var oXML = new XMLDocument(xURI, function() { var pckItemList = oXML.selectNodes("divList/row"); for (var i = 0; i < pckItemList.length; i++) { var pckItem = pckItemList[i]; addOption(xsrc, pckItem.selectSingleNode("mValue").text, pckItem.selectSingleNode("mCode").text); } xsrc.selectedIndex = 0; }); } function deptLink_onclick() { var xURL = document.getElementById("selectTopCatDept").value; if (xURL) { if (xURL.substr(0, 21).toLowerCase() == "http://www2.mof.gov.tw") location.href = xURL; else window.open(xURL, "_nwMof"); } }