Log in

View Full Version : making a simple calculator



s.m.
09-10-2008, 03:45 PM
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

magicyte
09-10-2008, 09:10 PM
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.

mburt
09-10-2008, 11:53 PM
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">

Twey
09-11-2008, 10:06 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>BMI Calculator</title>
<style type="text/css">
label {
display: block;
}
</style>
<script type="text/javascript">
onload = function() {
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>
</head>
<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.

s.m.
09-11-2008, 03:53 PM
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.:)

s.m.
09-11-2008, 03:59 PM
back already

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