function makerequest(url,PRODUCT,TableName,WhereValue,Object, AddNone, DefaultValue){ var http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } // 定義事件處理函數為 alterContents() http_request.onreadystatechange = function() { alertContents(Object, AddNone, DefaultValue,http_request); }; http_request.open('POST', url, true); http_request.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); http_request.send(null); } function alertContents(Object, AddNone, DefaultValue,http_request) { if (http_request.readyState == 4) { if (http_request.status == 200) { rtn_msg = http_request.responseText; //2012-06-25 [art] 先以XML string測試,之後再利用XMLHTTP抓到資料,把這個text換掉 //text = "香港SELECT DISTINCT T.CITY_CD, T.CITY_CNM, T.CITY_ENM FROM TRCITY T INNER JOIN TRCPN TC ON '/' + TC.MUT_CITY_CD + '/' LIKE '%/' + T.CITY_CD + '/%' WHERE TC.MUT_NATN_CD = 'CN' ORDER BY T.CITY_ENM" parser=new DOMParser(); xmlDoc=parser.parseFromString(rtn_msg,"text/xml"); CreateOption(Object, AddNone, DefaultValue); } else { alert('There was a problem with the request.'); } } } //2012-06-25 [art] 瀏覽器相容性:Firefox支援 if (window.ActiveXObject){ var xmlOption = new ActiveXObject("Microsoft.XMLDOM"); xmlOption.async = false; xmlOption.resolveExternals = false; xmlOption.load("SYS_GetOptions.asp"); } else if (document.implementation && document.implementation.createDocument) { var xmlOption=document.implementation.createDocument("","",null); } function GetOptions(PRODUCT, Object, TableName, WhereValue, AddNone, DefaultValue) { //alert("/script/SYS_GetOptions.asp?PRODUCT=" + PRODUCT + "&GetData=" + TableName + "&WhereData=" + WhereValue) //alert(xmlURL) var xmlURL = ""; //2012-06-25 [art] 瀏覽器相容性:Firefox支援 if (window.ActiveXObject){ xmlURL = "/include/SYS_GetOptions.asp?PRODUCT=" + PRODUCT + "&GetData=" + TableName + "&WhereData=" + WhereValue; xmlOption.load(xmlURL); CreateOption(Object, AddNone, DefaultValue); } else if (document.implementation && document.implementation.createDocument) { if (TableName!='TRCPCLS') { if (WhereValue=='-' || WhereValue=='--') { WhereValue=''}; } var postData = "PRODUCT=" + PRODUCT + "&GetData=" + TableName + "&WhereData=" + WhereValue; // 改為自動抓取本地網址 //2013-12-03[Aron]若有port會有問題,改用host //var GetHostName = location.hostname var GetHostName = location.host //2017-04-14[Luca]因ssl的緣故所以protocol改用抓的 var protocol = location.protocol var url = protocol + "//" +GetHostName +"/include/SYS_GetOptions_FF.asp?" + postData makerequest(url,PRODUCT,TableName,WhereValue,Object, AddNone, DefaultValue); } } function CreateOption(A, C, D) { //alert(xmlOption.readyState + '\n' + xmlOption.xml) A.innerHTML = ""; var TempOption = new Object(); //2012-06-25 [art] 瀏覽器相容性:Firefox支援 if (window.ActiveXObject){ var TempNodes = xmlOption.getElementsByTagName("Options"); }else{ var TempNodes = xmlDoc.getElementsByTagName("Options"); } if (C == 1) { TempOption = document.createElement("OPTION"); TempOption.value = "--"; TempOption.text = "請選擇"; A.add(TempOption); A.selectedIndex = 0; } //2011-11-02 [art] 給eWeb/HTL/L_HTL_Search用,增加不限選項。 if (C == 2) { TempOption = document.createElement("OPTION"); TempOption.value = "--"; TempOption.text = "不限"; A.add(TempOption); A.selectedIndex = 0; } //2014-12-15 Derrick 增加一個給票券用 if (C == 3) { TempOption = document.createElement("OPTION"); TempOption.value = ""; TempOption.text = "請選擇"; A.add(TempOption); A.selectedIndex = 0; } if (TempNodes.length == 0) { return; TempOption = document.createElement("OPTION"); TempOption.value = ""; TempOption.text = ""; A.add(TempOption); return; } //2012-06-25 [art] 瀏覽器相容性:Firefox支援 if (window.ActiveXObject){ for (var i = 0; i < TempNodes.length; i++) { var TempOption = document.createElement("OPTION"); TempOption.value = TempNodes(i).getAttribute("Value"); //TempValue; TempOption.text = TempNodes(i).text; A.add(TempOption); if (TempOption.value == D) {D = i + 1;} } }else { var cs = xmlDoc.getElementsByTagName("Options"); for(var i=0;i