Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
  <div class="row">
    <div class="col-md-12 lead">
      <h1>Rep Max Calc</h1> I did
      <input type="number" id="weight" class="weight" placeholder="Weight" pattern="[0-9]*"> for
      <select id="reps" class="reps">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
        <option value="8">8</option>
        <option value="9">9</option>
        <option value="10">10</option>
      </select>
      reps
    </div>
    <!--col input-->
  </div>
  <!--row input-->

  <div class="row">
    <div class="col-xs-6 table-responsive">
      <table class="table table-striped table-hover tablefontsize">
        <thead>
          <tr>
            <th>RM</th>
            <th>Average</th>
            <th><a href="http://en.wikipedia.org/wiki/One-repetition_maximum#Lombardi" target="_blank">Lombardi</a></th>
            <th><a href="http://en.wikipedia.org/wiki/One-repetition_maximum#Brzycki" target="_blank">Brzycki</a></th>
            <th><a href="http://en.wikipedia.org/wiki/One-repetition_maximum#Epley" target="_blank">Epley</a></th>
            <th><a href="http://en.wikipedia.org/wiki/One-repetition_maximum#Mayhew_et_al." target="_blank">Mayhew</a></th>
            <th><a href="http://en.wikipedia.org/wiki/One-repetition_maximum#O.27Conner_et_al." target="_blank">O'Conner</a></th>
            <th><a href="http://en.wikipedia.org/wiki/One-repetition_maximum#Wathan" target="_blank">Wathan</a></th>
            <th><a href="http://en.wikipedia.org/wiki/One-repetition_maximum#Lander" target="_blank">Lander</a></th>
          </tr>
        </thead>
        <tbody class="output">

        </tbody>

      </table>
    </div>
    <!--col table-->
  </div>
  <!--row table-->
</div>
<!--container-->
              
            
!

CSS

              
                .tablefontsize {
  font-size: 16px;
}

.weight {
  width: 90px;
  padding: 0.3em 0 0.3em 0.3em;
  font-size: 2rem;
}

.reps {
  font-size: 2rem;
  padding: 8px;
}
              
            
!

JS

              
                //All Things Gym Rep Max Calculator: http://www.allthingsgym.com/rep-max-calculator/
//To do: fancy charts?

$('#weight,#reps').on("keyup change", function() { //constantly fire when a weight is entered OR reps are changed, ain't nobody got time for submit buttons

  var output = $('.output'); //caching that so jQuery doesn't need to fetch it every time

  var RepMaxCalc = { //here we go

    init: function() { //the game plan
      this.getInput();
      this.calculateOneRM();
      this.calculateRMs();

    },

    getInput: function() { //read the input weight and reps

      RepMaxCalc.weight = $('#weight').val();
      RepMaxCalc.reps = $('#reps').val();

    },

    calculateOneRM: function() {

      //for all reps > 1 calculate the 1RMs    
      RepMaxCalc.lomonerm = RepMaxCalc.weight * Math.pow(RepMaxCalc.reps, 1 / 10);

      RepMaxCalc.brzonerm = RepMaxCalc.weight * (36 / (37 - RepMaxCalc.reps));
      RepMaxCalc.eplonerm = RepMaxCalc.weight * (1 + (RepMaxCalc.reps / 30));
      RepMaxCalc.mayonerm = (RepMaxCalc.weight * 100) / (52.2 + (41.9 * Math.exp(-1 * (RepMaxCalc.reps * 0.055))));
      RepMaxCalc.ocoonerm = RepMaxCalc.weight * (1 + RepMaxCalc.reps * 0.025);
      RepMaxCalc.watonerm = (RepMaxCalc.weight * 100) / (48.8 + (53.8 * Math.exp(-1 * (RepMaxCalc.reps * 0.075))));
      RepMaxCalc.lanonerm = RepMaxCalc.weight * 100 / (101.3 - 2.67123 * RepMaxCalc.reps);

      RepMaxCalc.avgonerm = (RepMaxCalc.lomonerm + RepMaxCalc.brzonerm + RepMaxCalc.eplonerm + RepMaxCalc.mayonerm + RepMaxCalc.ocoonerm + RepMaxCalc.watonerm + RepMaxCalc.lanonerm) / 7;

      output.empty(); //empty the table from previous outputs (needed because we continuously detect new inputs, which would lead to recalculations being added to the bottom of the table)

      // If reps = 1 display the entered weight as 1RM (instead of the >1RM results that some formulas give)
      if (RepMaxCalc.reps == 1) {

        output.append('<tr><td>' + '1RM' + '</td><td><strong>' + RepMaxCalc.weight + '</strong></td><td>' + RepMaxCalc.weight + '</td><td>' + RepMaxCalc.weight + '</td><td>' + RepMaxCalc.weight + '</td><td>' + RepMaxCalc.weight + '</td><td>' + RepMaxCalc.weight + '</td><td>' + RepMaxCalc.weight + '</td><td>' + RepMaxCalc.weight + '</td></tr>').find("td").css("font-size", "120%");
      } else {
        //append the 1RMs to the table, row by row
        output.append('<tr><td>' + '1RM' + '</td><td><strong>' + Math.floor(RepMaxCalc.avgonerm) + '</strong></td><td>' + Math.floor(RepMaxCalc.lomonerm) + '</td><td>' + Math.floor(RepMaxCalc.brzonerm) + '</td><td>' + Math.floor(RepMaxCalc.eplonerm) + '</td><td>' + Math.floor(RepMaxCalc.mayonerm) + '</td><td>' + Math.floor(RepMaxCalc.ocoonerm) + '</td><td>' + Math.floor(RepMaxCalc.watonerm) + '</td><td>' + Math.floor(RepMaxCalc.lanonerm) + '</td></tr>').find("td").css("font-size", "120%");
      }
    },

    calculateRMs: function() {

      // calculate RMs 2-10 and append it to the table
      var i = 2;
      for (i; i <= 10; i++) {

        RepMaxCalc.lomrm = Math.floor(RepMaxCalc.lomonerm / (Math.pow(i, 1 / 10)));
        RepMaxCalc.brzrm = Math.floor((RepMaxCalc.brzonerm * (37 - i)) / 36);
        RepMaxCalc.eplrm = Math.floor(RepMaxCalc.eplonerm / ((1 + (i / 30))));
        RepMaxCalc.mayrm = Math.floor((RepMaxCalc.mayonerm * (52.2 + (41.9 * Math.exp(-1 * (i * 0.055))))) / 100);
        RepMaxCalc.ocorm = Math.floor((RepMaxCalc.ocoonerm / (1 + i * 0.025)));
        RepMaxCalc.watrm = Math.floor((RepMaxCalc.watonerm * (48.8 + (53.8 * Math.exp(-1 * (i * 0.075))))) / 100);
        RepMaxCalc.lanrm = Math.floor(((RepMaxCalc.lanonerm * (101.3 - 2.67123 * i)) / 100));

        RepMaxCalc.avgrm = Math.floor((RepMaxCalc.lomrm + RepMaxCalc.brzrm + RepMaxCalc.eplrm + RepMaxCalc.mayrm + RepMaxCalc.ocorm + RepMaxCalc.watrm + RepMaxCalc.lanrm) / 7);

        //append the RMs to the table, row by row
        output.append('<tr><td>' + i + 'RM' + '</td><td><strong>' + RepMaxCalc.avgrm + '</strong></td><td>' + RepMaxCalc.lomrm + '</td><td>' + RepMaxCalc.brzrm + '</td><td>' + RepMaxCalc.eplrm + '</td><td>' + RepMaxCalc.mayrm + '</td><td>' + RepMaxCalc.ocorm + '</td><td>' + RepMaxCalc.watrm + '</td><td>' + RepMaxCalc.lanrm + '</td></tr>');
      }
    }
  }

  RepMaxCalc.init(); // initiate RepMaxCalc

});
              
            
!
999px

Console