Hi guys I wonder how can I display the data of "products" that is inside an array please see my code below
JSON Array
var places = [
{"country_name": "Denmark", "latitude": 56, "longitude": 10, "status": "OK", "site_name": "Denmark", "serial_number": "12345", "products":["1","2"]},
{"country_name": "Japan", "latitude": 56, "longitude": 10, "status": "OK", "site_name": "Norway", "serial_number": "12345", "products":["3","4"]},
{"country_name": "Denmark", "latitude": 56, "longitude": 10, "status": "OK", "site_name": "USA", "serial_number": "12345", "products":["7","6"]}]
Javascript
function displayData(e)
{
var html = '';
var mapDiv = document.getElementById('mapContainer'), i = 0,
dataIndex, tooltipDiv, key,
mapMarkers = $(mapDiv).find('.e-mapMarker'), index = 0;
var collection = [];
for (i = 0; i < mapMarkers.length; i++) {
if (e.target.parentNode.parentNode == mapMarkers[i]) {
index = i;
}
}
html += '<div id="infocontainer" class="map_element">';
html += '<div class="p-image"></div>';
html += '<div class="popupdetail">';
html += '<div class="p-name"> Site Name: ' + places[index].site_name + '</div>';
html += '<div class="p-name"> Site Status: ' + places[index].status + '</div>';
html += '<div class="p-name"> Country: ' + places[index].country_name + '</div>';
html += '</div>';
html += '</div>';
if (!document.getElementById('map_tooltip'))
{
tooltipdiv = $("<div></div>").attr('id', "map_tooltip");
$(document.body).append(tooltipdiv);
$(tooltipdiv).css({
"display": "none", "padding": "5px",
"position": "absolute",
"z-index": "13000",
"cursor": "default",
"font-family": "Segoe UI",
"color": "#707070",
"font-size": "12px", "pointer-events": "none",
"background-color": "#FFFFFF",
"border": "1px solid #707070"
});
}
else
{
tooltipdiv = $("#map_tooltip");
$(tooltipdiv).css({
"left": (e.pageX + 5),
"top": (e.pageY + 5)
});
$(tooltipdiv).html(html).show("slow");
}
}
so I want to render the "1","2" that is inside products or if I have multiple countries in array and I want to render a specific product array of a country so I hope I wont get any down vote for not clear english or explanations :-)