Skip to content

Instantly share code, notes, and snippets.

@CB9TOIIIA
Created December 21, 2015 07:34
Show Gist options
  • Save CB9TOIIIA/48d1c77125b02b4c8c28 to your computer and use it in GitHub Desktop.
Save CB9TOIIIA/48d1c77125b02b4c8c28 to your computer and use it in GitHub Desktop.
<td align="left" valign="top"><script src="//maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false&amp;libraries=places"></script>
<script>
var testPlace = 0;
var autocomplete;
function initialize() {
var input = document.getElementById('city');
var options = {
types: ['(cities)'],
//componentRestrictions: {country: country_code}
};
autocomplete = new google.maps.places.Autocomplete(input, options);
google.maps.event.addListener(autocomplete, 'place_changed', function() {
var place = autocomplete.getPlace();
if (!place.geometry) {
//document.getElementById('city').value = '';
return;
}
else {
testPlace = 1;
}
});
}
function GetCountryCode(country) {
document.getElementById('city').value = '';
if (country) {
autocomplete.setComponentRestrictions({'country': country});
document.getElementById('city_input').style.display = 'block';
}
else {
autocomplete.setComponentRestrictions({});
document.getElementById('city_input').style.display = 'none';
}
}
function CheckForm() {
var err;
/*
if (testPlace) {
document.getElementById('city_err').style.display = 'none';
document.getElementById('city').style.border = '1px solid gray';
}
else {
err = 1;
document.getElementById('city').value = '';
document.getElementById('city').style.border = '1px solid red';
document.getElementById('city_err').style.display = 'block';
}
if (document.getElementById('country').options[document.getElementById('country').selectedIndex].value) {
document.getElementById('country_err').style.display = 'none';
document.getElementById('country').style.border = '1px solid gray';
}
else {
err = 1;
document.getElementById('country').style.border = '1px solid red';
document.getElementById('country_err').style.display = 'block';
document.getElementById('city_input').style.display = 'none';
}
*/
if (err) {
alert('err');
}
else {
//alert('ok');
document.order.submit();
}
}
google.maps.event.addDomListener(window, 'load', initialize);
$(window).load(function(){
if(window.FileReader){
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#photo_pr').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function(){
readURL(this);
});
}
else {
//window.alert("Browser error!");
}
});
</script>
<h1>Город через Goolge API</h1>
<table width="450" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="left" valign="top">
<br>
<div id="country_err" style="float: left; margin-left: 15px; display: none;">
country error!
</div>
<!--<div style="clear: both; height: 10px;"></div>-->
<div id="city_input" style="display: block;">
<div style="float: left;">
<label for="city" title="Город">Город:</label>
<br>
<input id="city" name="city" style="border: 1px solid gray; width: 400px; padding: 4px; font-size: 12px; cursor: auto; background-image: url(&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABHklEQVQ4EaVTO26DQBD1ohQWaS2lg9JybZ+AK7hNwx2oIoVf4UPQ0Lj1FdKktevIpel8AKNUkDcWMxpgSaIEaTVv3sx7uztiTdu2s/98DywOw3Dued4Who/M2aIx5lZV1aEsy0+qiwHELyi+Ytl0PQ69SxAxkWIA4RMRTdNsKE59juMcuZd6xIAFeZ6fGCdJ8kY4y7KAuTRNGd7jyEBXsdOPE3a0QGPsniOnnYMO67LgSQN9T41F2QGrQRRFCwyzoIF2qyBuKKbcOgPXdVeY9rMWgNsjf9ccYesJhk3f5dYT1HX9gR0LLQR30TnjkUEcx2uIuS4RnI+aj6sJR0AM8AaumPaM/rRehyWhXqbFAA9kh3/8/NvHxAYGAsZ/il8IalkCLBfNVAAAAABJRU5ErkJggg==&quot;); background-attachment: scroll; background-position: 100% 50%; background-repeat: no-repeat;" type="text" placeholder="Введите местоположение" autocomplete="off">
</div>
<div id="city_err" style="float: left; margin-left: 15px; display: none;">
city error!
</div>
</div>
</td>
<td></td>
</tr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment