1
I’m developing a visual availability map, and I created a dynamic table, so far everything right. I need to get the result of <td>
and transform into images.
Example: my <td>
returns 900
, I need to change this value to an X image; mine <td>
returns 100
, change this value to image Y. understood?
Follow below my Javascript.
var div = document.getElementById("situacao1");
//var dataset = DatasetFactory.getDataset("colleague", null, null, null);
//var dataset = DatasetFactory.getDataset("dsEmpreendimentos", null, constraints, null);
try {
var dataset = DatasetFactory.getDataset("dsUnidadeVenda", null, constraints, null);
div.innerHTML = showDataset(dataset);
} catch(erro) {
div.innerHTML = erro;
}
}
function showDataset(dataset) {
var tabela = "<table id=minhaTabela>";
//Monta o cabeçalho
tabela += "<tr>";
for (var i = 0; i < dataset.columns.length; i++) {
tabela += "<th>" + dataset.columns[i] + "</th>";
}
tabela += "</tr>";
//Monta os registros
for (var x = 0; x < dataset.values.length; x++) {
tabela += "<tr>";
var row = dataset.values[x];
for (var y = 0; y < dataset.columns.length; y++) {
tabela += "<td id=td_sit>" + row[dataset.columns[y]] + "</td>";
}
tabela += "</tr>";
}
tabela += "</table>";
return tabela;
}
The return of Javascript in HTML is this.
There’s only one result column.
Bruno, you want to change the content of
<td>
of character 900, for a image?– RXSD
Without knowing the structure of the table becomes difficult, because it is not known which column you want to take the values... or would be all columns?
– Sam
only has a column that returns the code.
– Bruno Rayol
But what is the column? the first, the second, the third....
– Sam
I edited my question and put an image of the JS return in HTML.
– Bruno Rayol