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

143
Visualizações
how can i get the value of eventname into a js query?

I have the following partial as part of my assignment to show a list of events on my website, the problem is that I want to use the value called event name in a mongo dB query so I can append the users username to the attending array based on the name of the event

<ul>
<!-- for each user-->
<% events.forEach(function(event) { %>

<form action="/attend" method="post">
    <div class="Events">
      <div class="Post" id="Post1">
        <div class="PostTitle" name = "eventname"><%= event.name %></div>
        <div class="PostDate" name = "date"> <%= event.date %></div>
        <div class="PostDescription"><%= event.description %></div>
        <div class="PostAttending" name="AttendingNum"><%= event.attendingusers.length%></div>
        <div class="PostAttendingSymbol"><span>&#128100;</span></div>
        <button class="editbutton" type="submit">Attend</button> 
      </div>
    </div>
</form>

<% }); %>

during testing i have tried this code to get the value but it is coming back as undefined

app.post('/attend', function(req, res){

 var test = {
 "event" : req.body.eventname}

 var user = req.session.currentuser

 console.log(JSON.stringify(test))
 console.log(JSON.stringify(user))
});

any help would be great as I planned on using a process like this to delete events too

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is no name attribute for div. If you need to uniquely identify one, use id. In your case you can also use input of hidden type with the value assigned like this:

<input type="hidden" name="eventname" value="<%= event.name %>">
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