I'm extremely new to javascript so I've no idea if I'm doing this correctly.
I've got some php that is filling a javascript variable array:
<?php
$pages = get_pages(array('child_of' => $post->ID, 'sort_column' => 'menu_order'));
$data = array();
foreach($pages as $post){
setup_postdata($post);
$fields = get_fields();
$data[] = '<p>'.$fields->company_name.'</p>';
}
wp_reset_query();
// the js array
echo 'var marker_data = ["'.implode('","', $data).'"];';
?>
This then feeds this javascript:
infowindow.setContent(marker_data[i]);
The problem is that it's not incrementing. If I change the "i" to "0" or "1" then it works. But obviously I need it to increment through.