I want to create a table filled with information from an external source. I found a solution on the internet, but I want to change the view of the table. I can now build this table:
with this code:
function showInfo(evt) {
var f = 0;
var temstr = "";
if(evt.features.length != 0){
for (f = 0; f <= evt.features.length - 1; f++) {
if(evt.features[f].gml.featureType == "amice_om_herk"){
temstr = temstr + "<b>" + "<center>Herkomstlocatie</center>" + "</b>";
temstr = temstr + "<table>";
for ( var key in evt.features[f].attributes) {
temstr += "<tr>";
switch (key){
case 'afvlstrnum':
temstr += "<td width= 71px>Afvalstroomnummer</td><td>"
+ evt.features[f].attributes[key] + "</td>";
break;
case 'strnm_herk':
temstr += "<td width= 71px>Straat</td><td>"
+ evt.features[f].attributes[key] + "</td>";
break;
case 'hsnum_herk':
temstr += "<td width= 71px>Huisnummer</td><td>"
+ evt.features[f].attributes[key] + "</td>";
break;
case 'numtv_herk':
temstr += "<td width= 71px>Nummer toevoeging</td><td>"
+ evt.features[f].attributes[key] + "</td>";
break;
case 'plts_herk':
temstr += "<td width= 71px>Plaatsnaam</td><td>"
+ evt.features[f].attributes[key] + "</td>";
break;
default:
};
temstr += "</tr>";
}
temstr = temstr + "</table>";
};
}
log(temstr, true);
} else {
log("<b>Informatie</b><br/>" + "Niets gevonden op deze locatie", true);
}
}
But I want my table to look more like this:
In other words, flip my table with column names above the values instead of in the row of the value. What also might be a problem, is that if I click somewhere where there are multiple values on top of each other, I want the values underneath each other but keep one column name (like the picture above), and not like this:
Could someone help me with this? I'm not an experienced coder.