×
Namespaces

Variants
Actions
Revision as of 02:55, 8 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

BMI widget

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia N96
Compatibility
Platform(s): S60 3rd FP2,S60 5th Edition
Symbian
Platform Security
Capabilities: )
Article
Keywords: widget
Created: ck.umraliya (08 Jan 2009)
Last edited: hamishwillee (08 May 2013)

Contents

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

BMI.jpg

Widget download

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

This page was last modified on 8 May 2013, at 02:55.
96 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×