我对Google集成表单自动完成有问题。我已经实施了,并正常工作,直到我试图限制国家。
<script>
function initialize() {
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(40.802089, -124.163751)
);
var origin_input = document.getElementById('location');
//var isocode = document.getElementById('ISOcountry').val()
var options = {
bounds: defaultBounds,
types: ['(cities)'],
language: '<?php echo $lang['dataLanguage']?>',
//componentRestrictions: {country: isocode }
};
var autocomplete_origin = new google.maps.places.Autocomplete(origin_input, options);
}
google.maps.event.addDomListener(window, 'load', initialize);
如果我取消了componetRestrictions的2行注释,它就不起作用了,我也不明白为什么。
var isocode = document.getElementById('ISOcountry').val()从这里获取ISO国家值:
你们知道吗?
此外,我还想优化脚本,直接从这里附加的另一个脚本获取ISO代码:
$.post('libs/jsonISOcountry.php', { country : val }, populateISOcountry, 'html');
function populateISOcountry(data) {
$('#ISOcountry').html(data);
}页面jsonISOcountry.php的内容
//....DB connection.....
if (!empty($_POST['country'])) {
foreach ($conn->query("SELECT * FROM regions WHERE countryID=".$_POST['country']) as $row3) {
$html = $row3['isocountry'] ;
}
die($html);提前感谢您的帮助
发布于 2014-05-04 08:45:38
发现问题了!
var isocode = document.getElementById('ISOcountry').val() 不是在处理表单的隐藏字段!
与此改变,并正常工作!
var isocode = document.getElementById('ISOcountry').value;https://stackoverflow.com/questions/23450571
复制相似问题