+ 1
Hey guys,am In a process of creating a calculator to calculate surface area of a closed cylinder but my JavaScript has a problem
JavaScript calculate function
12 Answers
+ 3
Hi! can I ask you to show us your code? otherwise, it's just guessing on coffee grounds. describe the problem more specifically
+ 2
The formula is true but when I reload the code in my browser nothing seems functioning ,am trying to create a calculator
+ 1
Var num1=document.getElementById('radius');
Var num2=document.getElementById('height');
document.getElementById('result'). innerHTML=2*Math.PI*num1*num2+2*Math.PI*num1*num2;
+ 1
I run your code... and... fine news! He works (in generally)đ
+ 1
Hey bros would you mind sending a pic of it to my WhatsApp?
+ 1
your code produces the result, as far as your formula is true
however, I omitted the complex getElementById construction and used the usual prompt for input. Are you familiar with this built-in feature?
+ 1
I run it in my laptop but nothing was showing upđ
+ 1
to tell the truth, no, I can't. I modified it a little. so it will probably not suit you fully. but I can point out some errors to you. do you know how to use the coding platform that is located here?
+ 1
Yes I know
+ 1
your first mistake is in declaring variables. how does this happen? and Yes, place your code in the "codes {}" section. select this option, click the plus sign, select web, and drop your code there
+ 1
Would you mind sending me your WhatsApp number so I send you a pic of the code from my laptop right now?
0
Then the function before the code is
window.onload(){
function calculate (){
//The code above goes here
}
}