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

423
Vistas
How do you submit parameters from a input tag into a form onsubmit attribute in HTML?

I have 3 inputs, and I want to put their values into the form onsubmit attribute function. Here's my current code. I would like a way to do this that won't require me to create 3 variables using getElementById() or querySelector(), preferably in the HTML file, but if it's impossible, I'll accept defeat.

    <form id="form" onsubmit="addUserCredentials(userID, username, email)">
      <input type="text" id="userID" name="userID"></input>
        <label for="userID">User ID</label>
      
      <input type="text" id="username" name="username"></input>
        <label for="username">Username</label>
      
      <input type="text" id="email" name="email"></input>
        <label for="email">Email Address</label>

      <button>Submit</button>
    </form>

p.s. here's script.js if you want to look (and yes, i'm using firebase)

function addUserCredentials(userId, username, email) {
  db.ref('users/' + userId).set({
    username: username,
    email: email
  });
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The inputs will always be available in the form object with its name as the key and does not require to be passed as parameters so,

<form id="form" onsubmit="addUserCredentials()">
function addUserCredentials() {
  const userId = this.userID.value
  const username = this.username.value
  const email = this.email.value
}

this as the form element.

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