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

312
Views
¿Cómo obtener el valor del objeto en mi entrada de texto?

 var fname = document.getElementById("fName"); var lname = document.getElementById("lName"); const btnSave = document.getElementById("btnSave"); const btnDisplay = document.getElementById("btnDisplay"); btnSave.addEventListener("click", getData); function getData() { console.log( getFullName({ fname: `${fname.value}`, lname: `${lname.value}`, }) ); } function getFullName(FullName) { return FullName.fname + " " + FullName.lname; }
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <link rel="stylesheet" href="main.css" /> </head> <body> <input type="fName" placeholder="First Name" /> <input type="lName" placeholder="Last Name" /> <button id="btnSave">Save</button> <button id="btnDisplay">Display</button> <script src="main.js"></script> </body> </html>

¿Cómo obtener el valor del objeto en mi entrada de texto? Devuelve nulo. Pero cuando asigno valor en mi objeto como fName: "John", lName: "Doe" regresa con éxito.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

"fname" y "lname" no son identificadores. Ha asignado tipos incorrectamente en sus campos de entrada. En su lugar, haz algo como esto:

 <input type="text" id="fname" placeholder="First Name" /> <input type="text" id="lname" placeholder="Last Name" />
about 4 years ago · Santiago Trujillo Report

0

Sus elementos de entrada no tienen identificadores.

about 4 years ago · Santiago Trujillo Report

0

No agregó una identificación a sus etiquetas de entrada.

probar :

 <input id="fName" placeholder="First Name" /> <input id="lName" placeholder="Last Name" />
about 4 years ago · Santiago Trujillo 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!