Should I use a form for this

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • noritauhidi
    Corporal

    • Nov 2007
    • 10

    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, 11:21 PM. Reason: title change
  • Watdaflip
    Major General

    • Sep 2005
    • 2116

    #2
    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

    Comment

    • noritauhidi
      Corporal

      • Nov 2007
      • 10

      #3
      Re: Should I use a form for this

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

      Comment

      • Watdaflip
        Major General

        • Sep 2005
        • 2116

        #4
        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

        Comment

        • noritauhidi
          Corporal

          • Nov 2007
          • 10

          #5
          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>

          Comment

          • Watdaflip
            Major General

            • Sep 2005
            • 2116

            #6
            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

            Comment

            • noritauhidi
              Corporal

              • Nov 2007
              • 10

              #7
              Re: Should I use a form for this

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

              Comment

              Working...
              X