Javascript 城市和国家地图
我试图将自动完成输入字段中的内容与格式化的\u地址输出进行比较 我将自动完成限制为:Javascript 城市和国家地图,javascript,jquery,google-maps,maps,Javascript,Jquery,Google Maps,Maps,我试图将自动完成输入字段中的内容与格式化的\u地址输出进行比较 我将自动完成限制为: var options = { types: ['(cities)'], componentRestrictions: {country: "be"} }; 然后以格式化的_地址作为输出城市 一切正常,但对于某些城市,我在输出中添加了一个数字,无法进行比较 示例: -这是可比的 输入字段显示=Bruxelles,Belgique 格式化的_地址=比利时布鲁塞尔 -这是不可比的 输
var options = {
types: ['(cities)'],
componentRestrictions: {country: "be"}
};
然后以格式化的_地址作为输出城市
一切正常,但对于某些城市,我在输出中添加了一个数字,无法进行比较
示例:-这是可比的
输入字段显示=Bruxelles,Belgique
格式化的_地址=比利时布鲁塞尔 -这是不可比的
输入字段显示=Malone,Belgique
格式化地址=5020马隆,比利时 问题是:如何获得与显示的输入字段完全相同的输出
///////EDIT
我想我通过删除这些数字解决了这个问题:
//Delete numbers and spaces before output if they exist
while(from.charAt(0) == " " || (from.charAt(0) >= '0' && from.charAt(0) <= '9'))
{
from = from.substr(1);
}
//如果数字和空格存在,请在输出前删除它们
而(from.charAt(0)=“”| |(from.charAt(0)>='0'&&from.charAt(0)问题在于将输入字段与隐藏的城市输入字段进行比较。
为什么?
1.输入bruxelles
2.选择bruxelles
3.隐藏的城市==bruxelles,隐藏的latlong=(xx,xx)
如果提交->确定
如果键入blabla而不按enter键,
blabla将是具有先前latlong隐藏输入的输入字段
所以我想比较隐藏的城市和城市输入字段
解决方案:
键入->清除隐藏字段时
//Set from city hidden values to "" when typing again
var input1 = document.getElementById('connexion_inputcity');
input1.onkeydown = function() {
var key = event.keyCode || event.charCode;
if( key == 8 || key == 46 )
{
document.forms["inscription"]["check1"].value = "";
document.forms["inscription"]["LatLongFrom"].value = "";
}
};
input1.onkeypress = function () {
document.forms["inscription"]["check1"].value = "";
document.forms["inscription"]["LatLongFrom"].value = "";
};
//Set to hidden hidden values to "" when typing again
var input2 = document.getElementById('connexion_inputNdCity');
input2.onkeydown = function() {
var key = event.keyCode || event.charCode;
if( key == 8 || key == 46 )
{
document.forms["inscription"]["check2"].value = "";
document.forms["inscription"]["LatLongTo"].value = "";
}
};
input2.onkeypress = function () {
document.forms["inscription"]["check2"].value = "";
document.forms["inscription"]["LatLongTo"].value = "";
};
请将您的解决方案作为答案发布,我仍然没有解决问题。请参阅新编辑