0
I want to know how to increment a number to a JS variable every time it goes through the while loop. For example:
var num2 = 1;
while(num2 < num){
new google.maps.Marker({
position: posicao(incrementar valor de num2 aqui),
title: nome(incrementar valor de num2 aqui),
map: map
});
num2++;
}
But you’re already doing it...
– echojn
No, man. I want the value of num2 to be increased to the position and name variables. Like, they’ll start as: posicao1 and name1, then posicao2 and Nome2, and so on.
– Higor Cardoso
But
position
andtitle
sanestrings
? You can give examples of values they have ?– Isac
Guys, solving this problem would also help me: https://answall.com/questions/309026/como-chamar-fun%C3%A7%C3%A3o-js-via-php. Since I’m only trying this way used in this post because I didn’t get the link post way
– Higor Cardoso
Isac, both are variables that are receiving BD values, for example: position: -9.838877963370699 -39.485223973571806 and name: test marker
– Higor Cardoso
The use of
eval()
is not very recommended, but in these cases I see no problem:position: eval('posicao'+num2),
– Sam
I suggest making the question as clear as possible, to avoid that those who answer have to edit several times because they have not got exactly what you want. Put an example of
position
andtitle
before and after being "increased".– Isac
People, with the link(https://jsfiddle.net/qc0g5j8f/) @dvd posted already solved the problem. Thank you all
– Higor Cardoso