I'm trying to create a form that allows for calculation of metabolic rate.
There is an if,then statement related to gender (formula changes if female vs male)
I'd also like the result to be targeted to a specific part of the page (anchor). Ideally a new section can appear (maybe need to link a new page?) to provide further details
Below is my code, any help would be so appreciated!!
<head><style>
body {font:15px gothic, sans-serif;letter-spacing:1px;}
input {width:100%;}
input[type=number]{border: none;border-bottom:1px solid grey;}
input[type=button], input[type=submit], input[type=reset]{background-color:#ddcecb;border: none;-moz-border-radius:5px;-webkit-border-radius:5px;color:#95483e;padding:16px32px;text-decoration: none;letter-spacing:1px;margin:4px2px;#submit:hover {border: none;background:#d2d1d1;box-shadow:0px0px1px#777;}}
input[type=text]:focus {border:1px solid #555;}.form-inline label {margin:5px10px5px0;}@media(max-width:800px){.form-inline input {margin:10px0;}.form-inline {flex-direction: column;align-items: stretch;}</style></head><formname="RMRcalc">
weight (kg) :
<inputtype="number"name="weight"autofocus><br><br>
height (cm):
<inputtype="number"name="height"><br><br>
age (years):
<inputtype="number"name="age"><br><br>
activity Level:
<selectname="activity"margin=5px><optionvalue="1.2">sedentary (1-2x/week)</option><optionvalue="1.3">low (2-3x/week)</option><optionvalue="1.4">moderate (3-4x/week)</option><optionvalue="1.6">high (5+x/week)</option></select><br><br>
female <inputtype="radio"name="gender"value="female"checked><br>
male <inputtype="radio"name="gender"value="male"><br><inputtype="submit"value="Calculate"id="calculate"onclick="RMRCalc()"target="results"><br><br><scripttype="text/javascript">"use strict"functionRMRCalc(){var weight = document.getElementById ("weight").value;var height = document.getElementById("height").value;var age = document.getElementById("age").value;var activity = document.getElementById("activity").value;if(gender="female")var RMR =(10*weight)+(6.25*height)-(5*age)-161;
document.getElementById("RMR").innerHTML=RMR;elsevar RMR =(10*weight)+(6.25*height)-(5*age)+5; document.getElementById("RMR").innerHTML=RMR;}</script></form><p><aname="results">
Your Daily Caloric Requirements:
<divid="RMR"></div></a></p><br><p>
Did you know that
Form Calculation Help
in HTML/XHTML
Posted
I'm trying to create a form that allows for calculation of metabolic rate.
There is an if,then statement related to gender (formula changes if female vs male)
I'd also like the result to be targeted to a specific part of the page (anchor). Ideally a new section can appear (maybe need to link a new page?) to provide further details
Below is my code, any help would be so appreciated!!
Thank you!!