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

196
Views
Not able to get form data using getelementbyId from Html to JS

I am just beginning with programming and starting with javascript. I am not able to get a form filled in html and get it into javascript by getElementById. Could you please take a look at my code and tell me a solution.

HTML form

input type="text" id="myText"
input type="submit" id="submit"

javascript

var x = document.getElementById("myText").value;
console.log(x);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you put some value into you input field it should work. Please check the example (https://codepen.io/alekskorovin/pen/abLOzBw):

 var x = document.getElementById("myText").value; console.log(x);
<input type="text" id="myText" value="test" />

Of course if you want dynamic value in the input - you have to make it empty and then add some event handler, inside that handler use that code var x = document.getElementById("myText").value; console.log(x);

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!