I have following code thas is being loaded across all pages ( all fuctions are included at once ). But inputs location1 and location2 exist only one of these pages. And is not affecting funcilonality, but each time I inspect javascript logs on the pages where these inputs do not exist I get error "InvalidValueError: not an instance of HTMLInputElement" (Firefox).
JavaScript:
var autocomplete1 = new google.maps.places.Autocomplete($("#location1")[0], {});
google.maps.event.addListener(autocomplete1, 'place_changed', function() {
var place1 = autocomplete1.getPlace();
});
var autocomplete2 = new google.maps.places.Autocomplete($("#location2")[0], {});
google.maps.event.addListener(autocomplete2, 'place_changed', function() {
var place2 = autocomplete2.getPlace();
});
and very basic form inputs (which a prefiled) on this spacific pagewhere console error doesnt show up:
HTML:
<input type="text" class="form-control" id="location1" name="location1" value="<?php echo"$location1"; ?>">
<input type="text" class="form-control" id="location2" name="location2" value="<?php echo"$location2"; ?>">
I wonder what I can do to avoid this error? Any advice