onsubmit がいくつかの機能を実行するフォームがあります。func2(); であることを確認するにはどうすればよいですか。func1(); の場合にのみ実行されます。正常に実行されますか? そして func3(); 2と1がした場合のみ?
<form onsubmit="func1();func2();func3(); return false">
<input type="text" id="start" name="start">
<input type="submit" value="Go">
</form>
たとえば、関数の 1 つは次のようなものです。
<script src="https://maps.googleapis.com/maps/api/js?&sensor=false&region=it&libraries=places"></script>
<script>
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var myLatlng = new google.maps.LatLng(41.88994,12.51383);
var mapOptions = {
zoom:16,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: myLatlng,
styles: [
{
featureType: "poi.business",
elementType: "labels",
stylers: [
{ visibility: "off" }
]
}
]
}
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('directions-panel'));
var input = document.getElementById('start');
var options = {
types: ['geocode'],
componentRestrictions: {country: 'it'},
rankBy: google.maps.places.RankBy.DISTANCE
};
var autocomplete = new google.maps.places.Autocomplete(input, options);
autocomplete.bindTo('bounds', map);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Studio medico'
});
}
function calcRoute() {
var start = document.getElementById('start').value;
var end = "Via Tiburtina 500, Roma";
var request = {
origin:start,
destination:end,
travelMode: google.maps.DirectionsTravelMode.TRANSIT
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
他の2つは次のとおりです。
function boxappear() {
document.getElementById("percorsolink").style.display="none";
document.getElementById("percorsoform").style.display="inline";
}
function reducemap() {
document.getElementById("map-canvas").style.width="620px";
google.maps.event.trigger( map, "resize" );
}