// change log // created: 2021-05-09 //populates the drop down dropDownIdToPopulate on selecting a value in drop down selectedItemId function populateDropDown(selectedRegions, selectedcities, allRegions, dropDownIdToPopulate, populateVendorCities){ //create the http request checking for mozilla vs ie if (window.XMLHttpRequest) { httpRequest = new XMLHttpRequest(); if (httpRequest.overrideMimeType) { httpRequest.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } //make sure the request was created properly if (!httpRequest) { //changed to return true so that the form proceeds return true; } //selectedItem = document.getElementById(selectedItemId); //set our call back function to be called once the info is processed httpRequest.onreadystatechange = function() { startPopulatingWithSelect(selectedRegions, selectedcities, allRegions, httpRequest, dropDownIdToPopulate); }; //query string '&popVenCts' will get cities the vendor have registered or else, get all the cities for the region populateCities = ''; if(populateVendorCities == 1){ populateCities = '&popVenCts'; } //make the url to be called var regionsString = ''; for(var i=0; i < selectedRegions.length; i++) { regionsString = regionsString + 'rid[]=' + selectedRegions[i] + '&'; } var url = 'newgetCities.php?' + regionsString + populateCities; try { httpRequest.open('GET', url, true); } catch(e) { //if there is any kind of error opening the request we will return true so that the form submits via normal http return true; } //headers httpRequest.setRequestHeader("Connection", "close"); //send the request httpRequest.send(null); //set the return to false so that the form is not submitted via html return false; } //populates the drop down box dropDownIdToPopulate from the xml elements in httpRequest function startPopulatingWithSelect(selectedRegions, selectedcities, allRegions, httpRequest, dropDownIdToPopulate){ if (httpRequest.readyState == 4) { if (httpRequest.status == 200) { //for debugging uncomment the following line var xmldoc = httpRequest.responseXML; var cities = xmldoc.getElementsByTagName('cities').item(0); var selectedCityIndex = 0; var new_cities; var ddown =document.getElementById(dropDownIdToPopulate); new_cities = ''; ddown.innerHTML = ''; var xmlCitiesArray = new Array(); for(var i=0; i < cities.childNodes.length; i++){ var cityId = cities.childNodes[i].getAttribute('id'); var regionId = cities.childNodes[i].getAttribute('region_id'); var cityName = cities.childNodes[i].firstChild.data; xmlCitiesArray[i] = new Array(regionId, cityId, cityName); } //adding the cities to the drop down box var allTop = 0; var top = 0; for(var k=0;k < allRegions.length; k++) { var selectThisRegion=false; for(var t=0; t < selectedRegions.length; t++) { if(selectedRegions[t]==allRegions[k][1]) selectThisRegion = true; } if(selectThisRegion==true) new_cities = new_cities + '