Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!