HEX
Server: Apache/2.4.41
System: Linux mainweb 5.4.0-182-generic #202-Ubuntu SMP Fri Apr 26 12:29:36 UTC 2024 x86_64
User: nationalmedicaregrp (1119)
PHP: 8.3.7
Disabled: exec,passthru,shell_exec,system,popen,proc_open,pcntl_exec
Upload Files
File: /home/healthinsuranceapproval/public_html/OLD/js/zipCodeLookup.js
function zipCodeLookup() {
	var zipCapture = document.getElementById("zipCode").value;
	var clientKey = "AIzaSyDgyonK-CqlFEUVGBYE1l87Zwcxf0FyskY";
	const Http = new XMLHttpRequest();
	const url= "https://maps.googleapis.com/maps/api/geocode/json?&address="+zipCapture+"&key=" + clientKey;
	Http.open("GET", url);
	Http.send();
	Http.onreadystatechange = function() {
		if (zipCapture.length != 5) {
			document.getElementById("zipCode").classList.remove("zipCodeInput");
			document.getElementById("zipCode").classList.remove("zipCodeInputValid");
		    document.getElementById("zipCode").classList.add("zipCodeInputInvalid");
		    document.getElementById("displayLocation").classList.remove("hide");
		    document.getElementById("displayLocation").classList.add("show");
		    $('#displayLocation').hide();
	            
		    

		  }
		  else {
			$.ajax({ url:"https://maps.googleapis.com/maps/api/geocode/json?&address="+zipCapture+"&key=" + clientKey,
			success: function(data){
				var addressObject = data.results[0].address_components;
				/*or you could iterate the components for only the city and state*/
			
		  	document.getElementById("zipCode").classList.remove("zipCodeInput");
		  	document.getElementById("zipCode").classList.remove("zipCodeInputInvalid");
		  	document.getElementById("zipCode").classList.add("zipCodeInputValid");
		    console.log(addressObject[0].short_name)
		    var zip = addressObject[0].short_name;
	        var city = addressObject[1].short_name;
	        var state =addressObject[3].short_name;
	        var county = addressObject[2].short_name;
	        document.getElementById("displayLocation").innerHTML = "Search in " + city + ", " + state;
	        document.getElementById("city").value = city;
	        document.getElementById("state").value = state;
	        document.getElementById("zip").value = zip;
	        console.log(county, city, state);
	        document.getElementById("displayLocation").classList.remove("show");
		document.getElementById("displayLocation").classList.add("hide");
		$('#displayLocation').show();
		}
	});
		$('#displayLocation').show();
		
		}
    };
}

$('#zipCode').on('input',function(){
	zipCodeLookup();	
})