var script = "/home/xml.php?"; var xmlHttpRequest; var ajax_opt_set = new Object; /*################################################# # Create and load the data using the XMLHttpRequest ##################################################*/ function loadXmlData(url, object) { // create the object, careful to the MSFT/Other method if (window.XMLHttpRequest) { xmlHttpRequest = new XMLHttpRequest(); } else if (window.ActiveXObject) { xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } // executing the request, passing the targetted object xmlHttpRequest.open("GET", url, true); xmlHttpRequest.onreadystatechange = function () {processRequestChange(object)}; xmlHttpRequest.send(null); } // End of function /*############################################## # Handle the events of the XMLHttpRequest Object ###############################################*/ function processRequestChange(object) { if (xmlHttpRequest.readyState == 4) { if (xmlHttpRequest.status == 200) { copyList( object.id ); } else { alert("Error loading page\n"+ xmlHttpRequest.status + ":" + xmlHttpRequest.statusText + "Object: " + object.id); } // end of the request, change the status zone // document.getElementById("statusZone").innerHTML = prior(); } else { // Indicates that the client is *busy* // document.getElementById("statusZone").innerHTML = "Loading..." } } // End of function /*########################################################### # Load the Cat data in the select object # (Could be done in a generic manner depending of the XML...) ############################################################*/ function loadCat() { var url = script; var target = document.getElementById("cat"); loadXmlData(url,target); } // End of function /*########################################################### # Load the Brand data in the select object # (Could be done in a generic manner depending of the XML...) ############################################################*/ function loadBrand() { var target = document.getElementById("brand"); var modelTarget = document.getElementById("model"); var seriesList = document.getElementById("series"); var catList = document.getElementById("cat"); clearList(target); clearList(modelTarget); clearList(seriesList); var url = script + catList.value; // alert(url); loadXmlData(url,target); } // End of function /*########################################################### # Answer the question: Does the selected series have the # model specified? ############################################################*/ function checkModel() { var modInp = document.getElementById("model"); var model = modInp.value; var series = document.getElementById("series").value; var url = script + series + "/" + model xmlHttpRequest.open("GET", url, true); xmlHttpRequest.onreadystatechange = function () {alertYN(model)}; xmlHttpRequest.send(null); } // alertYN: // returns 1 (yes), 0 (no), or -1 (no answer yet) // ---------------------------------------------- function alertYN(model) { var xx = -1; if (xmlHttpRequest.readyState == 4) { if (xmlHttpRequest.status == 200) { xx = xmlHttpRequest.responseXML.getElementsByTagName("KEY")[0].firstChild.nodeValue; if( 1 == xx ) alert(model + " is an existing model."); } else { alert("Error loading page\n"+ xmlHttpRequest.status + ":" + xmlHttpRequest.statusText + "Checking for " + model); } // end of the request, change the status zone // document.getElementById("statusZone").innerHTML = prior(); } else { // Indicates that the client is *busy* // document.getElementById("statusZone").innerHTML = // "Checking for " + model + "..." } return xx; } // End of function /*########################################################### # Load the Series data in the select object # (Could be done in a generic manner depending of the XML...) ############################################################*/ function loadSeries() { var target = document.getElementById("series"); var catList = document.getElementById("cat"); var modelList = document.getElementById("model"); var brandList = document.getElementById("brand"); clearList(target); clearList(modelList); var url = script + brandList.value; loadXmlData(url,target); } // End of function /*########################################################### # Load the Model data in the select object # (Could be done in a generic manner depending of the XML...) ############################################################*/ function loadModel() { var seriesList = document.getElementById("series"); var target = document.getElementById("model"); var catList = document.getElementById("cat"); var brandList = document.getElementById("brand"); clearList(target); var url = script + seriesList.value; loadXmlData(url,target); } // End of function /*########################################################### # Populate the list with the data from the request # (Could be done in a generic manner depending of the XML...) ############################################################*/ function copyList( id ) { var list = document.getElementById(id); if( list.copyProc ) { list.copyProc( xmlHttpRequest ); } else { clearList(list); addElementToList(list, "Choose.. ", "Choose.. " ); list.disabled=false; var items = xmlHttpRequest.responseXML.getElementsByTagName("ROW"); var selected = 0; var s = ''; for (var i=0; i '' ) { eval( ajax_opt_set['next'] ); ajax_opt_set['next'] = ''; } } } // End of function /*############################# # remove the content of te list ##############################*/ function clearList(list) { while (list.length > 0) { list.remove(0); } } // End of function /*##################################### # Add a new element to a selection list ######################################*/ function addElementToList(list, value, label) { var option = document.createElement("option"); option.value = value; var labelNode = document.createTextNode(label); option.appendChild(labelNode ); list.appendChild(option); } // End of function