Results 1 to 7 of 7

Thread: Should I use a form for this
      
   

  1. #1
    noritauhidi is offline Corporal
    Join Date
    Nov 2007
    Posts
    10

    Default Should I use a form for this

    Hi, I want to create an RMR calculator for my website, I'm not even sure if you would use a form to do this but I'm pretty sure you would. So what I want to do is allow people to put in their sex, age, height and weight, and then I want it to calculate the persons RMR for them, with the formula I put in. So I was wondering what would allow me to add a formula to calculate all these variables that the visitor would add in and then how can I display the results to them.

    Thank you very much.
    Last edited by noritauhidi; 12-26-2007 at 10:21 PM. Reason: title change

  2. #2
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default Re: Should I use a form for this

    The best two ways would be to either use php or javascript, either way there is no feature in BV to do this. You are correct that a form is needed, basically a set of text fields and possibly drop down menus, and just taking the values entered for each and making the calculations. But to do the calculations you have to use a programming language like php or javascript (php requiring that the form submit, javascript dynamically making the calculations without the page refreshing

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

  3. #3
    noritauhidi is offline Corporal
    Join Date
    Nov 2007
    Posts
    10

    Default Re: Should I use a form for this

    where would I get a java script code to do this?

  4. #4
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default Re: Should I use a form for this

    You might be able to find existing code for what you are looking for, a google search will probably provide the best results for that.

    Otherwise you have to learn javascript and write the code yourself

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

  5. #5
    noritauhidi is offline Corporal
    Join Date
    Nov 2007
    Posts
    10

    Default Re: Should I use a form for this

    I tried this basic javascript code, asking the visitor to input their weight, height, and age, but when I click calculate it doesn't work, nothing comes up. I keep messing around with it but I can't figure out whats wrong, its my first attempt at a javascript code so I don't really know what I'm doing. Any suggestions?



    <html>
    <head>
    <script language="JavaScript">
    <!-- hide this script from old browsers

    function rmrcalc(form)

    {

    var age = 0;

    var height = 0;

    var weight = 0;

    rmr =
    ((5.0033)height + (13.751)weight – age(6.755) + 66.473);
    form.rmrcalc.value = cal;

    }
    // done hiding from old browsers -->
    </script>

    </head>

    <body>

    <FORM>

    <h2>RMR Calculator</h2>

    Enter Weight, Height, and Age:

    <INPUT NAME="height" VALUE="0" MAXLENGTH="15" SIZE=15>
    <p>
    <INPUT NAME="weight" VALUE="0" MAXLENGTH="15" SIZE=15>

    <p>

    <INPUT NAME="age" VALUE="0" MAXLENGTH="15" SIZE=15>
    <p>
    Click this button to calculate RMR:

    <INPUT NAME="rmrcalc" VALUE="Calculate" TYPE=BUTTON
    onClick=rmrcalc(this.form)
    <p>
    Your RMR is:
    <INPUT NAME="RMR" READONLY SIZE=15>

    </FORM>

    </body>

    </html>

  6. #6
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default Re: Should I use a form for this

    function rmrcalc(form)
    {

    var age = 0;

    var height = 0;

    var weight = 0;

    rmr =
    ((5.0033)height + (13.751)weight – age(6.755) + 66.473);
    form.rmrcalc.value = cal;

    }


    should be something more like

    function rmrcalc(form)
    {
    var age = document.form.age.value;
    var height = document.form.height.value;
    var weight = document.form.weight.value;
    document.form.rmrcalc.value =( (5.0033)*height + (13.751)*weight – age*(6.755) + 66.473 );
    }

    I didn't test this so it might not work

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

  7. #7
    noritauhidi is offline Corporal
    Join Date
    Nov 2007
    Posts
    10

    Default Re: Should I use a form for this

    It didn't work for me, but I appreciate the effort, thanks a lot

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49