Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

BMI widget

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



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

<link rel="StyleSheet" href="BMI.css" type="text/css" />
<script type="text/javascript" src="BMI.js" />
<body bgcolor="#CDCDB4">
<!-- Get data -->
<div id="mainView">
<h2>Your Health</h2>
<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>
<label for="ht">Enter your height(in cm):</label>
<input class="input" type="text" id="ht" size="4" value=""/>
<label for="wt">Enter your weight(in kg):</label>
<input class="input" type="text" id="wt" size="4" value=""/>
<input class="button" type="button" name="calc" value="CALCULATE" onClick="showResult();" />
<!-- Show Result -->
<div id="resultView">
<h2>Your Health</h2>
<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>


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]



Widget download

Rename the file to BMI.wgz before installation.

This page was last modified on 7 May 2013, at 23:55.
71 page views in the last 30 days.