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

224
Vistas
not getting value in html from with javaScript

I am not getting value in the alert box I am trying to get all values by using function with onclick. It gave me an empty value so how do I get all value with this keyword.

form

<form>
  <input type="text" id='textid' />
  <button class="btn" type="submit" onclick="myfunc(this);">click</button>
</form>

function

function myfunc(el){
  let x = el.value;
  alert(x) }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are alerting value of button, instead you should first get the input and then get its value using .value property

const input = document.querySelector("input");

function myfunc(el) {
  let x = input.value;
  alert(x)
}
<form>
  <input type="text" id='textid' />
  <button class="btn" type="submit" onclick="myfunc(this);">click</button>
</form>

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