Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

201
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda