ボタンをクリックして場所を検索しています。結果はonclickボタンになります。しかし、私が送信機能に入れたのと同じコードですが、ここでは検索が機能していません。
ボタンクリックコード(これは機能しています)
$("#gobuttton").click(function() {
$("#gmaplatlon").validate({
rules:{"latitude":{number:true}, "longitude":{number:true}, "zoom":{digits:true,min:0}},
errorPlacement:errorMessages
});
$("#address").change(function(){
geocoder.geocode({"address": $(this).attr("value")}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setZoom(16); map.setCenter(results[0].geometry.location); } else { alert("Geocode was not successful for the following reason: " + status); } });
});
});
Enterボタンコードを押します(同じですが機能しません)
$('#frm').keypress(function(e) {
var code = e.keyCode;
if(code === 13){
e.preventDefault();
alert(code);
$("#gmaplatlon").validate({rules:{"latitude":{number:true}, "longitude":{number:true}, "zoom":{digits:true,min:0}}, errorPlacement:errorMessages});
$("#address").change(function(){ geocoder.geocode({"address": $(this).attr("value")}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setZoom(16); map.setCenter(results[0].geometry.location); } else { alert("Geocode was not successful for the following reason: " + status); } }); });
}
});
私の機能は-テキストボックスにアドレスを入力してEnterキーを押すと、Googleマップで検索されます。これはボタンクリックで実行されますが、Enterキーが押されたときは実行されません。
HTMLコードは次のとおりです
<form method="post" name="frm" id="frm" enctype="multipart/form-data" action="<?php echo site_url('home/sendmapdata');?>">
<input name="address" type="text" id="address" border: solid 1px; " size="60" value="Search from address" onClick="this.value=''">
<input type="button" id="gobuttton" value="go">
<div id="map_canvas" style="height: 480px; width:665px; " ></div>
<input type="hidden" name="gmaplatlon" value="true">
<p align="center">
<input type="submit" name="okbutton" value="OK" >
</p>
</form>