Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

243
Visualizações
How can I add element from my express server to my html table?

I want to add an element from server.js using express to my table in my html file. I know you can use double curly braces like "{{example}}" in the html file to import a value from the server file using res.render(views, options). But I wonder if there is a way to add a new row to a table like this :

index.html :

<table>
    <tr>
        <th>Description</th>
        <th>Adress</th>
    </tr>
    <tr>
        <td>{{description}}</td>
        <td>{{adress}}</td>
    </tr>

</table>

which add a new row everytime I call my res.render() method. Here what I have in my server file :

server.js :

app.get('/index', (req, res) => {
    var values = []
    var cursor = dbo.collection('collection').find()
    cursor.forEach(function (doc, err) {
        if (err) throw err;
        values.push(doc.name);
        values.push(doc.adress)
    }, function () {
        res.render('index', {description: values[0], adress: values[1]})
    })
})
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Express is a backend server which can set the value in the page to be pushed to front end. To add new rows to a rendered html at Front End , please use a combination of AJAX / Javascript

about 4 years ago · Juan Pablo Isaza Relatório

0

The ejs templating engine supports Javascript statements like the cursor.forEach in the template. Look, for example, at the <ul> example on the npm page.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda