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

141
Views
Cómo usar la función onkeydown para actualizar el valor de Celsius en el convertidor de grados a Farenheit

Decidí crear una utilidad web que ayudará a las personas a realizar conversiones fáciles de grados a Farenheit. Cada elemento html en la página se muestra como se esperaba, el único problema es el javascript...

Metodología

Utilicé javascript onkeydown() para registrar el método que responderá a las pulsaciones del teclado en el campo de entrada de grados. Esta función llama a otra función llamada update() que se supone que obtiene la entrada que el usuario ingresó en el campo de grados, la procesa y muestra el resultado en el campo farenheit. Excepto que parece haber un problema en la función de actualización. No sé si es así como estoy accediendo a las propiedades de los campos de entrada y asignando... por favor ayuda

Código

 <!DOCTYPE html> <html> <head> <title>Degrees to Farenheit Converter </title> <!--add dependencies--> <link rel="stylesheet" href="materialize/css/materialize.min.css"/> <link rel="stylesheet" href="mystyle.css"/> </head> <body> <div class="container"> <center><h5>Convert Degrees to Farenheit</h5></center> <center><h5>Temp in Degrees:</h5><input class="form-control"type="number" id="degrees" onkeydown="update()"/><br/></center> <center><h5>Temp in Celsius</h5><input class="form-control"type="number" id="farenheit"/></center> </div> </body> <script type="text/javascript"> let degree=document.getElementbyId("degrees"); let far=document.getElementById("farenheit"); //iplement a function that will listen on text //change inside the farenheit field function update(){ //alert("a key was pressed"); //get the number and convert to farenheit let temp=parseInt(degree.value); //convert to farenheit and display in th other //boex let faren=1.8*temp+32; //display the result in the celsius field far.value=faren; } </script> </html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Javascript distingue entre mayúsculas y minúsculas, y usted escribe document.getElementbyId() cuando el correcto es document.getElementById()

 let degree = document.getElementById("degrees"); let far= document.getElementById("farenheit"); //iplement a function that will listen on text //change inside the farenheit field function update(){ //alert("a key was pressed"); //get the number and convert to farenheit let temp=parseInt(degree.value); //convert to farenheit and display in th other //boex let faren=1.8*temp+32; //display the result in the celsius field far.value=faren; }
 <div class="container"> <center><h5>Convert Degrees to Farenheit</h5></center> <center><h5>Temp in Degrees:</h5><input class="form-control"type="number" id="degrees" onkeyup="update()"/><br/></center> <center><h5>Temp in Celsius</h5><input class="form-control"type="number" id="farenheit"/></center> </div>

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!