# Thread: making a simple calculator

1. New Comer (less than 5 posts)
Join Date
Sep 2008
Posts
3
Thanks
1
Thanked 0 Times in 0 Posts

## making a simple calculator

Hello

I need a simple BMI calc (Body Mass Index) to put on a website (it's a noob website, cause i only know basic html, i have to make it for a school project, tough i've never learned html or css except 1 time i've read a book about it.. and i'm only 15 x)
anyway, could some1 make the codes for it, and tell/guide me how to put it on if it needs more than just copy pasting?

it has to look like this:

- put in your weight (in Kilograms) example: 80 (kg)
- put in your Lenght (in meters, example: 1.75 (m))

then make it do the calc "Weight devided by Length²" (the BMI calc) example 80/1.75²

if 1 would make it for me, i would be thankfull!

thx!

Sam
Last edited by s.m.; 09-10-2008 at 03:51 PM.

2. Check out Google. Google for a "Body Mass Index Calculator Code". This should give you some code for it. BTW, you should learn MORE than just HTML. Try out this web-design website. It includes a bunch of programming information and tutorials - even for the TOTAL NON-PROGRAMMER!!!

You should try.

-magicyte

P.S. You are older than me.

3. Code:
```Weight:
<input type="text" id="weight">
Length:
<input type="text" id="length">
<input type="button" value="Calculate " onclick="_ = function(e){return document.getElementById(e);};
_('output').value = (_('weight').value / (_('length').value*_('length').value))">
<input id="output">```

4. ## The Following User Says Thank You to mburt For This Useful Post:

s.m. (09-11-2008)

5. Code:
```<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<title>BMI Calculator</title>
<style type="text/css">
label {
display: block;
}
</style>
<script type="text/javascript">
document.forms.bmi_calc.onsubmit = function() {
var e = this.elements;
document.getElementById('bmi_output').firstChild.nodeValue
= e.weight.value
/ Math.pow(e.height.value, 2);
return false;
};
};
</script>
<body>
<form id="bmi_calc" action="/server/side/equivalent">
<fieldset>
<legend>BMI Calculator</legend>
<label>Height: <input type="text" name="height"></label>
<label>Weight: <input type="text" name="weight"></label>
<label>BMI: <span id="bmi-output">NaN</span></label>
<input type="submit" value="Calculate">
</fieldset>
</form>
</body>
</html>```
tough i've never learned html or css except 1 time i've read a book about it.. and i'm only 15 x)
You're only a few years younger than me, and I know you're older than some here. Read http://www.howtocreate.co.uk/ — this should get you started.

6. New Comer (less than 5 posts)
Join Date
Sep 2008
Posts
3
Thanks
1
Thanked 0 Times in 0 Posts
thx guys, testing out now.
@ magicyte; ye i know i should,
and i'm gonna, but i havn't really got a deacent pc for a long time, and i'm mostly bussy with other things. trying out css and php etc. in a few weeks :]

anyways, thx, i'll come back to you to tell if it does/doesn't work.

7. New Comer (less than 5 posts)
Join Date
Sep 2008
Posts
3
Thanks
1
Thanked 0 Times in 0 Posts

hey mike, yours works perfect!
thx man, i'll add you to the 'thanks to' page if you don't mind?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•