} // 函數體 //學院下拉框事件 function showCollegeInfo(){ var selectIndex = document.getElementById("college").selectedIndex;//獲得是第幾個被選中了 var value = document.getElementById("college").options[selectIndex].value; if(value) { // 先創建一個對象實例 createXmlHttpRequestObject(); // 使用事件對象獲取文本框ID的值 var vCollege = value;
var url = "college.php?xy="+vCollege; //待發送URL url=encodeURI(url); xmlHttp.onreadystatechange=ajaxok; // 判斷瀏覽器狀態欄 (接收玩數據觸發的事件) xmlHttp.open("GET",url,false); // GET向服務器端發送數據 xmlHttp.send(null); document.getElementById("collegeinfo").style.display="block";//顯示學院信息的div }else{ document.getElementById("collegeinfo").style.display="none";//隱藏學院信息的div } } function ajaxok() { if(xmlHttp.readyState == 4 xmlHttp.status==200) { document.getElementById("collegeinfo").innerHTML = xmlHttp.responseText; } } //專業下拉框事件 function showMajorInfo(){ var selectIndex = document.getElementById("major").selectedIndex;//獲得是第幾個被選中了 var value = document.getElementById("major").options[selectIndex].value; if(value) { // 先創建一個對象實例 createXmlHttpRequestObject(); // 使用事件對象獲取文本框ID的值 var vMajor = value;