You Are Here:

Community: Wiki

This page was last modified on 8 January 2009, at 15:20.

BMI widget

From Forum Nokia Wiki


ID ... Creation date January 8, 2009
Platform S60 3rd FP2,S60 5th Edition Tested on devices Nokia N96
Category Web Runtime (WRT) Subcategory  


Keywords (APIs, classes, methods, functions): widget

Overview

BMI is a simple widget application which takes a person's height and weight and based upon that data it calculates the Body Mass Index of a person. BMI widget shows how we can put different images and text in a view based upon the calculation result we get. The widget package is attached below.

html code

<html>
<head>
<link rel="StyleSheet" href="BMI.css" type="text/css" />
<script type="text/javascript" src="BMI.js" />
</head>
 
<body bgcolor="#CDCDB4">
<!-- Get data -->
<div id="mainView">
<h2>Your Health</h2>
<h3>
<p>The Body Mass index is a statistical measurement which compares a person's weight and height.It is useful to measure a healthy body weight based on how tall a person is.</p>
</h3>
<p>
<label for="ht">Enter your height(in cm):</label>
<input class="input" type="text" id="ht" size="4" value=""/>
</p>
<p>
<label for="wt">Enter your weight(in kg):</label>
<input class="input" type="text" id="wt" size="4" value=""/>
</p>
<input class="button" type="button" name="calc" value="CALCULATE" onClick="showResult();" />
</div>
 
<!-- Show Result -->
<div id="resultView">
<h2>Your Health</h2>
<h3>
<U>BMI categories</U>
<p> BMI < 18.5 : UnderWeight</p>
BMI = 18.5-24.9 : Normal Weight
<p> BMI = 25-29.9  : Over Weight</p>
<p>BMI > 30 : Obesity</p>
 
<p id="output1"></p>
<p id="output2"></p>
<img id="sign" src="" />
<p id="output3"></p>
</h3>
</div>
</body>
</html>

Javascript

Following is the part of javascript file which calculates the BMI:

function calculate()
{ //Get height and Weight of user
URheight = document.getElementById("ht").value;
URweight = document.getElementById("wt").value;
 
//Calculate BMI
BMI = (10000*URweight)/(URheight*URheight);
 
//Assign image and text according to BMI
if (BMI < 18.50) {
var imgSrc = 'img/uw.png';
return [BMI, word[1], imgSrc]
}
 
if (BMI > 18.50 && BMI < 25) {
var imgSrc = 'img/ft.png';
return [BMI, word[0], imgSrc]
}
 
if (BMI > 25 && BMI < 30) {
var imgSrc = 'img/ow.png';
return [BMI, word[2], imgSrc]
}
 
if (BMI > 30) {
var imgSrc = 'img/ob.png';
return [BMI, word[3], imgSrc]
}
}

ScreenShot

Image:BMI.jpg

Widget download

Rename the file to BMI.wgz before installation. BMI.zip

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fPortingE5fBlackBerryE5fapplicationsE5fandE5fservicesE5ftoE5fS60E5fplatformX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZseriesE5f60Q qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxs60X qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ