JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<div class="container">
<div class="row">
<div class="col-md-12">
<strong>Height:</strong>
<div id="heightslider" class="slider"></div>
<div id="heightslidein">0ft</div>
<p>
<input type="text" id="input_height" style="display: none;">
</p>
<hr>
</div>
<div class="col-md-12">
<strong>Weight:</strong>
<div id="weightslider" class="slider"></div>
<div id="weightslidelb">0lb</div>
<input type="text" id="input_weight" style="display: none;">
<br>
<div type="button" id="calculatebutton" class="btn btn-primary">Calculate</div>
<div id="result"></div>
</div>
<div class="form-group">
<select name="height-ft" id="height-ft" class="form-control">
<option value="12">1'</option>
<option value="24">2'</option>
<option value="36">3'</option>
<option value="48">4'</option>
<option value="60">5'</option>
<option value="72">6'</option>
<option value="84">7'</option>
</select>
</div>
<div class="form-group">
<select name="height-in" id="height-in" class="form-control">
<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">7"</option>
<option value="9">9"</option>
<option value="10">7"</option>
<option value="11">7"</option>
</select>
</div>
</div>
</div>
JavaScript
/* BMI Calculator */
$('#weightslider').slider({
animate: true,
range: 'min',
min: 0,
max: 200,
step: 1,
slide: function(event, ui) {
$('#weightslidekg').html(ui.value + 'kg');
$('#weightslidelb').html((ui.value * 2.20462).toFixed(0) + 'lb');
},
change: function(event, ui) {
$('#input_weight').attr('value', ui.value);
}
});
$('#heightslider').slider({
animate: true,
range: 'min',
min: 100,
max: 250,
step: 1,
slide: function( event, ui ) {
$( "#heightslidecm" ).html( ui.value + 'cm' );
var inches = (ui.value*0.393700787).toFixed(0);
var feet = Math.floor(inches / 12);
inches %= 12;
$( "#heightslidein" ).html( feet + "ft " + inches + 'in');
},
change: function(event, ui) {
$('#input_height').attr('value', (ui.value / 100));
}
});
$('#calculatebutton').click(function() {
var weight = $('#input_weight').val(),
height = $('#input_height').val(),
heightsqaured = (height) * (height),
result = (weight) / (heightsqaured);
if (result < 16) {
var rating = ('You are severely underweight');
} else if (result > 16 && result < 18.5) {
var rating = ('You are underweight');
} else if (result > 18.5 && result < 25) {
var rating = ('You are healthy');
} else if (result > 25 && result < 30) {
var rating = ('You are overweight');
} else if (result > 30 && result < 35) {
var rating = ('You are moderately obese');
} else if (result > 35 && result < 40) {
var rating = ('You are severely obese');
} else if (result > 40 && result < 80) {
var rating = ('You are very severely obese');
} else if (result > 80) {
...