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

140
Views
How to use the onkeydown function to update celsius value in degree to farenheit converter

I decided to build a web utility that will help people do easy conversions from degrees to farenheit. Every html element on te page is rendering as expected, the only problem is the javascript...

Methodology

I used the javascript onkeydown() to register the method that will be responding to keyboard presses on the degrees input field. This function calls another function called update() that is supposed to get the input the user entered in the degrees field, process it and display the result in the farenheit field. Except that there seems to be a problem in the update function. I do not know if its the way am accessing the input fields properties and assigning...please help

Code

<!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 is case-sensitive, and you write document.getElementbyId() when the right one is 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!