Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi experts!

I need to create an online calculator from these inputs: width, length and height, and display the answer in m³. The length and width measurs are in meters, the height (this is a tricky part) in centemeters.

Found the base of that code from internet and modified a bit. (Look into JSFiddle/). Basically it does what i need – calculates the sum from three values (first two are in meters, third in centemeters), but i would like it to be more simpler. I don’t want “select options” at the end of a height (thickness) field. this value:


..else if(select_val == "meter"){
    result = result/100;
    $("#answer").text(result).append(" m<sup>3</sup>");;...



must have programmed into code by default!
please help me to simplify that code! or maybe you can provide more elegant solution?

my english is not good, but i still hope you understood my request

What I have tried:

tried to solve it myself, but... couldn't
Posted
Updated 15-Sep-16 4:59am
Comments
[no name] 15-Sep-16 9:18am    
Your question is "how to simplify 3 lines of code"?
Member 12741783 16-Sep-16 5:29am    
no, the whole code.
Patrice T 15-Sep-16 10:07am    
Ask the author to help you.

1 solution

Simplified
Calculator - JSFiddle[^]
 
Share this answer
 
Comments
Member 12741783 16-Sep-16 5:26am    
yes you did, but you forget one very important thing: you need to convert thickness value (cm) into meters to get result in m3. final result must be in m3!
Karthik_Mahalingam 16-Sep-16 5:28am    
ok, wait.i willupdate it.
Karthik_Mahalingam 16-Sep-16 5:30am    
check this fiddle https://jsfiddle.net/0L8s0ngg/5/
Member 12741783 16-Sep-16 5:35am    
looks good!! thank you very much!
Karthik_Mahalingam 16-Sep-16 5:36am    
if this works pls close this post by clicking "Accept Answer" button. so that this post will be closed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900