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

137
Vistas
Data value not stored in variables (showing undefined)

I am not able to store the input in the variables after submitting my form. It shows "undefined" Here's the code:

var userInput1 = document.getElementById("inp1").value;
  var userInput2 = document.getElementById("inp2").value;
 var userInput3 = document.getElementById("inp3").value;
function king() {
document.write("Welcome " + userInput1)
return false;
}```
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Check this example. It's fun to use JQuery too for shorter Syntaxes. (My example is pure JS)

function fetch(){
  var name = document.getElementById("name").value;
  var age = document.getElementById("age").value;
  
  //display
  document.getElementById("demo").innerHTML = 'Welcome "' + name + '" Your age is: "'+ age +'"';
}
<!DOCTYPE html>
<html>
<body>
<fieldset>
<legend>Sample</legend>
  <label>Name:</label>
  <input type="text" id="name"/>
  <br><br>
    <label>Age:</label>
  <input type="number" id="age"/>
  <br><br>
  <button onclick="fetch()">Fetch Data</button>
</fieldset>
<p id="demo"></p>
</body>
</html>

about 4 years ago · Santiago Gelvez 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