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

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

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 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!