Answer the question
In order to leave comments, you need to log in
How to loop through objects in ejs?
var punishments = {}; //объект "штрафы"
app.get('/driver', function (req, res) {
res.render('driver',
{
PunNum:punishments.num_punishment,
PunName:punishments.name_breakdown,
PunSum:punishments.coast,
PunCount:'0'//должно быть колличество объектов(кол-во штрафов)
});
});
function queryDatabasePunish() {
request = new Request(`SELECT punishments.num_punishment, breakdowns.coast, punishments.name_breakdown FROM breakdowns INNER JOIN punishments ON breakdowns.num_breakdown = punishments.num_breakdown WHERE (punishments.num_ptc = '${password}')`, function (err, rowCount, rows) {
console.log(rowCount + ' row(s) вернулось из штрафов');
});
request.on('row', function (columns) {
columns.forEach(function (column) {
punishments[column.metadata.colName] = column.value;//заполнение объекта
});
});
abcdef.execSql(request);
}
punishments = {};
<div id="block_punish" class="block_punish">
<h2>Информация о штрафах</h2>
<i>У ВАС <%=PunCount%> ШТРАФОВ</i>
<p>Номер протокола: <%=PunNum%></p>
<p>Название нарушения: <%=PunName%></p>
<P>Дата фиксации нарушения: </P>
<p>Сумма: <%=PunSum%></p>
</div>
Answer the question
In order to leave comments, you need to log in
<% for (var n=0; n<(locals.length); n++) {%>
<% if (JSON.stringify(locals[n * 3]) === undefined) break;%>
<p>Номер протокола: <%- JSON.stringify(locals[n * 3])%></p>
<p>Название нарушения: <%- JSON.stringify(locals[3 * n + 2])%></p>
<P>Дата фиксации нарушения: </P>
<p>Сумма: <%- JSON.stringify(locals[3 * n + 1])%></p>
<hr>
<% } %>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question