SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: Calculation

Threaded View

  1. #1
    SitePoint Addict
    Join Date
    Aug 2008
    0 Post(s)
    0 Thread(s)


    Okay this is my first try at doing some calculations using javascript...and I think you will see that. ha

    So here is an image showing what I'm trying to accomplish.

    I'm trying to do this calculation (((220 -Age in years -Resting Hear Rate) * .5) + Resting Heart Rate) and then
    concatenate it with (((220 -Age in years -Resting Hear Rate) * .65) + Resting Heart Rate)

    A couple starting questions that I have are

    1) How do I leave the variable blank? var Years; and Var RestingHeartRate;
    2) Do I have to run a loop to get the data that is entered into the fields??


            <p >Your heart rate during exercise will determine what benefits you receive from your workout.  Your 
    heart rate is meaured in beats per minute.  The heart rate range that you exercise in has been
    called “target heart rate training zones”.     
        <form action="" id="HeartRateForm" onchange="CalculateFatHeartRates()">
        <div class="left" style="margin-top:-10px; margin-bottom:15px; width:775px;font-size:14px; font-weight:bold;">
            <p style="font-size:20px;">Calculate your training "zones"</p>
            <br />
                <span style="margin-left:70px; font-size:12px; font-weight:200;"> <input type="text" name="Years" /> years</span>
            <label>Enter your resting heart rate: 
                <span style="margin-left:70px; font-size:12px; font-weight:200;"><input type="text" name="RestingHeartRate" /> Beats Per Minute (BPM)</span> <span style="margin-left:290px; font-weight:100px;" ><a  href="#"> Need help? </a></span>
            <p class="calculated accented">Fat Burning "zone" <span><span id="onerepmax">&nbsp;</span> lbs. <!--(estimate)--></span></p>
           <!-- <p class="calculated accented">Cardiovascular fitness "zone" <span><span id="strength">&nbsp;</span> %</span></p>-->
           <script type="text/javascript">
        var Years;
        var RestingHeartRate;
         var BaseHeartRate=220;
    function CalculateFatHeartRates(Years,RestingHeartRate,BaseHeartRate)    
    var CalculatedHeartRateGoal= (((BaseHeartRate - Years - RestingHeartRate) * .50) + RestingHeartRate) + "to" + 
    (((BaseHeartRate - Years - RestingHeartRate) * .65) + RestingHeartRate);
    <p style="font-size:18px; font-weight:bold; margin-bottom:-10px;">Your target heart rate training "zones" are:   <span style="font-size:16px; float:right;">Beats per minute (BPM)   </span>  </p>
      <p  style="float:right;  margin-bottom:80px; background-image:url(../../includes/images/Fat_Burning_Zone.png); width:780px; height:89px;"><span id="FatBurningHeartRate" style="float:right; margin-right:40px; font-size:16px; margin-top:35px; color:#c88d1c;">  </span> <p>     
    <p  style="background-color:#c88d1c; width:758px; color:#ffffff; float:right; margin-top:-80px; margin-right:2px; padding-top:10px; padding-bottom:10px; padding-left:10px; padding-right:10px;"> Exercising in your "fat burning zone" will increase the percentage of Calories that you burn from fat.  However, it won't increase the number of TOTAL Calories that you burn.  </p>
    Last edited by spikeZ; Nov 13, 2012 at 05:25.


Posting Permissions

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