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

200
Views
How do I display multiple inputs?

const form = document.querySelector("#user-form");
const userInput = document.querySelector("#name", "#surname", "#age", "#country");
const userList = document.querySelector(".list-group");
const firstCardBody = document.querySelectorAll(".card-body")[0];
const secondCardBody = document.querySelectorAll(".card-body")[1];
const filter = document.querySelector("#filter");
const clearButton = document.querySelector("#clear-users");
<form id="user-form" name="form">
  <div class="form-row">
    <div class="form-group col-md-6">
      <input class="form-control" type="text" name="name" id="name" placeholder="İsim">
    </div>
    <div class="form-group col-md-6">
      <input class="form-control" type="text" name="surname" id="surname" placeholder="Soyadı">
    </div>
    <div class="form-group col-md-6">
      <input class="form-control" type="text" name="age" id="age" placeholder="Yaş">
    </div>
    <div class="form-group col-md-6">
      <input class="form-control" type="text" name="country" id="country" placeholder="Ülke">
    </div>
  </div>
  <button type="submit" class="btn btn-primary">Bilgilerinizi Kaydedin</button>
</form>

My form looks like this. But when I run my JS code, it only shows me the name not surname, age or country. How do I display all of them?

enter image description here

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

0

document.querySelector cannot be use the way you use it as it returns the first matched element (in your case the name input). To get all input fields you can do it like this:

const userInput = document.querySelectorAll(".form-control");

This returns all 4 input fields in an array which can be iterated via

userInput.forEach(input => { ... });

Get a specific element like this:

Array.from(userInput).find(input => input.id === "name");

Another approach would be to get the input fields via their ID's:

const name = document.querySelector("#name");
const surname= document.querySelector("#surname");
const age = document.querySelector("#age");
const country = document.querySelector("#country");
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!