Advanced Search

Results 1 to 6 of 6

Thread: making a simple calculator

  1. #1
    Join Date
    Sep 2008
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation 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. #2
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    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. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    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">
    - Mike

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

    s.m. (09-11-2008)

  5. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <!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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #5
    Join Date
    Sep 2008
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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. #6
    Join Date
    Sep 2008
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    back already

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

Bookmarks

Posting Permissions

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