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/healthvaluequotes/public_html/backup2/js/zipCodeLookup.js
function zipCodeLookup(id) {
    var city, state, zip;
    if(id == '1')
    {
    zip = $('#zipCode').val();
    }
    if(id == '2')
    {
    zip = $('#zipCode2').val();
    }	
    var clientKey = "AIzaSyCAq_c3m1vTOYIu3FwmKJyFjELkkueBVow";
    if (zip.length === 5) {	  
    $.ajax({
      type:"GET",
      url:`https://maps.googleapis.com/maps/api/geocode/json?address=${zip}&key=${clientKey}`,
      }).done(function(response)
      {
          console.log(response);			
            var address_components = response.results[0].address_components;
            $.each(address_components, function(index, component){
              var types = component.types;
              $.each(types, function(index, type){
                if(type == 'locality') {
                  city = component.long_name;
                   $('.city').val(city);
                }
                if(type == 'administrative_area_level_1') {
                  state = component.short_name;
                  $('.state').val(state);	
                  $('.displayLocation').text(`In ${$('#city').val()}, ${$('#state').val()}`);
                  $('.displayLocation2').text(`In ${$('#city').val()}, ${$('#state').val()}`);			 
                }
              });
            });
          });
        }
    };