• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Math Related / Metric BMI Calculator

Metric BMI Calculator

Metric BMI Calculator

Use this script for a BMI calculator (Body Mass Index). Measurements are computed using the metric system. A perfect addition for a health Web site.

  1. Copy the coding into the HEAD of your HTML document
  2. Add the last code into the BODY of your HTML document
<!– STEP ONE: Paste this code into the HEAD of your HTML document  –>

<HEAD>

<script type=”text/javascript”>
<!– This script and many more are available free online at –>
<!– The JavaScript Source!! http://javascriptsource.com –>
<!– Created by: Bob Mason :: http://www.omega-cottage.co.uk/WLS –>
<!– Begin
function  calculateBMI() {
  var weight = eval(document.form.weight.value)
  var height = eval(document.form.height.value)
  var height2 = height / 100
  var BMI = weight  / (height2 * height2)
  document.form.BodyMassIndex.value=custRound(BMI,1);
}

function custRound(x,places) {
  return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places)
}
// End –>
</script>
</HEAD>
<!– STEP TWO: Copy this code into the BODY of your HTML document  –>

<BODY>

<div align=”center”>
<form  name=”form” id=”form”>
<input type=”Text” name=”weight” size=”4″> Weight (in Kilos)  
<input type=”Text” name=”height” size=”4″> Height (in Centimeters)<br><br>
<input type=”Text” name=”BodyMassIndex” id=”BodyMassIndex” size=”4″> BMI     
<input type=”button” style=”font-size: 8pt” value=”Calculate” onClick=”calculateBMI()” name=”button”>
<input type=”reset” style=”font-size: 8pt” value=”Clear Form”>
</form>
</div>

<p><center>
<font face=”arial, helvetica” size”-2″>Free JavaScripts provided<br>
by <a href=”https://javascriptsource.com”>The JavaScript Source</a></font>
</center><p>

Math Related

Related Snippets:

  • Amazing Quadratic Equation Solver
  • Distance Speed Time
  • Take a number and return it in the specified currency formatting
  • Generate a random number in a given range with JavaScript

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers