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

218
Views
Want to connect input with variable in Java Script

I want to suggest a variable which contain data by user from input section and store it into my variable so how I can do this in JavaScript? I suggest a = .... but that does not work as expected

let a = document.getElementById("link");

function lol() {
  document.getElementById("print").innerHTML = `a`;
}
<input type="text" id="link" name="link">
<button id="btn" onclick="lol()">Upload Video</button>
<p id="print"></p>

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You have to pass event and it's target value not only make reference from input to paragraph.

Adrian

about 4 years ago · Juan Pablo Isaza Report

0

function lol() {
  document.getElementById("print").innerText = a.value;
}

Use innerText instead of innerHtml to avoid html syntax passed through that input.

If you put variable name in parentheses it will treat it as text and not variable.

And a is input field with many options, to access value you use a.value

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!