J'ai créé un menu déroulant simple, avec des fonctions. Et puis j'ai réalisé qu'après avoir exécuté la fonctionA, je ne pouvais plus l'exécuter. Je dois exécuter functionB (une autre fonction) avant de pouvoir à nouveau exécuter functionA ... Puis-je savoir comment résoudre ce problème? Voici mes codes.Problèmes avec le menu déroulant et ses fonctions
Merci!
function changeForm(the_form)
{
window.location = the_form;
}
//Add Markers by Latitude and Longitude, automatically
//Listen for click
function marker()
{
google.maps.event.addListener(map, 'click', function(event) {
addMarker(event.latLng);
});
}
// Place markers in by click
function addMarker(location) {
marker = new google.maps.Marker({
position: location,
map: map,
title:"Specified Location",
icon: 'images/greenPoint.png'
});
markersArray.push(marker);
}
// Choose By Latitude and Longitude, manually
function admarker()
{
var lat = prompt("Enter latitude (-90 to 90)", "0");
while ((lat < -90) || (lat > 90))
{
alert("Latitude must be between -90 to 90");
var lat = prompt("Enter latitude (-90 to 90)", "0");
}
var lng = prompt("Enter longitude (-180 to 180)", "0");
while ((lng < -180) || (lng > 180))
{
alert("Longitude must be between -180 to 180");
var lng = prompt("Enter latitude (-180 to 180)", "0");
}
lat = parseInt(lat);
lng = parseInt(lng);
var latlng = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({
position: latlng,
map: map,
clickable: true,
title:"Specified Location",
icon: 'images/bluePoint.png'
})
var infiwindow = new google.maps.InfoWindow({
content: "Place where you have chosen!"
});
google.maps.event.addListener(marker,'mouseover',function(){
infiwindow.open(map,marker);
});
google.maps.event.addListener(marker,'mouseout',function(){
infiwindow.close(map,marker);
});
}
<form name = "formTwo">
<select name = "the_select" onChange = "changeForm(this.value);">
<option value = "#">- - Add Markers By Lat & Long - -</option>
<option value = "javascript:admarker()">Add Markers Manually</option>
<option value = "javascript:readMarker()">Add Markers Automatically</option>
</select></form>
Vous devez formater encore une fois. Utilisez l'icône 101010 pour mettre en retrait 4 espaces afin qu'il apparaisse comme code – mplungjan
pourriez-vous également s'il vous plaît envoyer le code de 'functionA' et' functionB'. –