View Full Version : 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
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">
<!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.
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.:)
back already
hey mike, yours works perfect!
thx man, i'll add you to the 'thanks to' page if you don't mind?
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.