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

109
Views
Value of e.target.value undefinned

I have a let: valorImput, coming from an e.target.value from input. I use this value to compare it with a value in an array and it works. But when I want to get its value it said undefined and I'm not able to use it in future functions. This is a link to Codesand with the whole code.

let valorImput = ""; 
dropDown.onchange = (e) => {
          valorImput = e.target.value;
          console.log("dropdown onchange console", e.target.value);
};
    
btn.onclick = (e) => {
      const existe = productos.find((x) => x.titulo === valorImput);
      existe ? (precio = existe.precio) : console.log("NO hay Nada");
      document.getElementById("valorDeSelect").value = precio;
       Swal.fire("El precio esta expresado en Dolares!", "USD " + precio, "success");
console.log("valor input", valorImput);
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Variable valorImput must be declared in global scope (outside of any "{}" brackets).

jsfiddle

See the documentation for more detail.

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!