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

216
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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