Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All,
How to calculate human being height in jquery. I have three textbox for entering the value for height in cms,inches,foot. I wrote some code for foot it is working fine. But i want to convert from inches to foot,cms and cms to inches,foot.
Below is my code

JavaScript
var feet = 0;
var inch = 0;
var cms = 0;
$('.feet').each(function () {
   if ($(this).val() != '' && $.isNumeric($(this).val())) {
       inch = parseFloat($(this).val() * 12);
       cms = parseFloat($(this).val() * 30.48);
   }
});
if (inch != 0 && cms != 0) {
   $("#<%=txtInches.ClientID%>").val(inch);
   $("#<%=txtCms.ClientID %>").val(cms);
}
else {
   $("#<%=txtInches.ClientID%>").val('');
   $("#<%=txtCms.ClientID %>").val(cms);
}
return false;
working above code
-----------------------------------------------------------------------------------
$('.inch').each(function () {
   if ($(this).val() != '' && $.isNumeric($(this).val())) {
       feet = parseFloat($(this).val() * 0.08);
       cms = parseFloat($(this).val() * 2.54);
       alert(parseFloat($(this).val() * 0.08));
       alert(cms);
   }
});

if (feet != 0 && cms != 0) {
   $("#<%=txtFeet.ClientID%>").val(feet);
   $("#<%=txtCms.ClientID %>").val(cms);
}
else {
   $("#<%=txtInches.ClientID%>").val('');
   $("#<%=txtCms.ClientID %>").val('');
}
return false;



Please reply me as early as possible


Thanks
Hari
Posted
Updated 31-Jan-14 3:03am
v2
Comments
Ankur\m/ 31-Jan-14 7:36am    
You haven't told us about the issue with your code.
phil.o 31-Jan-14 10:07am    
We already know the answer : that's 42.
Sergey Alexandrovich Kryukov 31-Jan-14 19:06pm    
42 in jqueries. This is such a unit of measurement, 1.0 jQuery, 38.7 jQueries, 42 jQueries... "In jQueries I'm much taller than in inches"... :-)
—SA
phil.o 31-Jan-14 20:29pm    
Magic thing is it's the same result for every unit you could imagine.
More explanation here ;)
Sergey Alexandrovich Kryukov 31-Jan-14 21:08pm    
Of course. Who would doubt? :-)
—SA

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