I'm trying to implement a javascript for loop in which a php variable is counting (phpVar++) each loop. However, the variable, which starts at 0, always ends up being 1, even though the loop loops multiple times.
Is this not possible?
<script>
<?php $totalMarkers=0; ?>
for (var i = 0; i < markers.length; i++) {
<?php $totalMarkers=$totalMarkers+1; ?>
}
<?php echo $totalMarkers ?> //this always prints "1"
</script>
I'm trying to do this so that I can print $totalMarkers in different places in the Body of the HTML.