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

164
Views
Grab multiselect values from a form NodeJS MySQL

I am trying to fetch multi-select values from a form.

JS Code

router.post('/profile', (req, res)=>{
    console.log(req.body.name);
})

HTML /profile

<div class="form-group" method="POST">
    <br>
    <select class="form-control multiselect" multiple="multiple">
    {{#team}}
        <option value="{{name}}" name="{{name}}">{{name}}</option>
    {{/team}}
    </select>
    <div class="form-group">
        <button type="submit" class="btn btn-primary btn-block">Update Members<i class="icon-circle-right2 ml-2"></i></button>
    </div>
</div>

On submitting I am not able to log the body.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There are multiple issues within your code.

  • First of all, since you are passing a variable as a name name="{{name}}", I assume that variable has a value equal to name[], notice you need to add array brackets to send multiple values for the same key.
  • Also method="POST" attribute should be added to form tag, not div.

In the end, your code should be similar to the code below:

<form method="POST">
    <div class="form-group">
        <br>
        <select class="form-control multiselect" multiple="multiple" name="name[]">
        {{#team}}
            <option value="{{name}}" >{{name}}</option>
        {{/team}}
        </select>
        <div class="form-group">
            <button type="submit" class="btn btn-primary btn-block">Update Members<i class="icon-circle-right2 ml-2"></i></button>
        </div>
    </div>
</form>

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!