My submit button is not executing anyone know wy
Please post your actual code instead of a picture. Thanks!
Can you please also give us more information? What do you mean by “not executing”? What happens when the button is pushed? What do you expect to happen? Do you get any error messages? What debugging steps have you already tried?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="assigment.css" />
</head>
<body>
<h1 style="text-align:center;">Basal Metabolic rate Calculator</h1>
<fieldset>
<div>
<ul>
<li style="display:inline;"><a href=#>Metric</a></li>
<li style="display:inline;"><a href=#>Imperical</a></li>
</ul>
</div>
<div id="content">
<h1 >BMR Metric</h1>
<label for="sex">Sex:
<select id="sex" name="sex">
<option value="female" >Female</option>
<option value="male">Male</option>
</select></label><br />
<label for="age">Age:
<input type="number" id="age" name="age"/></label> <br />
<label for=" height">Height:
<input type="number" id="height"name="height" /></label> <br />
<label for="Weight">Weight:
<input type="number" id="weight"name="weight" />
<br />
<input type="submit" value="Calculate BMR" />
<script src="assigment1.js"></script>
</label>
<script src="assigment1.js"></script>
</div>
</fieldset>
</body>
</html>
my javascript
function calculateBMR() {
var age = document.getElementById("age").value;
var height = document.getElementById("height").value;
var weight = document.getElementById("weight").value;
var sex = document.getElementById("sex").value;
var bmr;
if (sex == "female") {
bmr = 655 + (9.563 * weight) + (1.850 * height) - (4.676 * age);
}
else {
bmr = 66.5 + (13.75 * weight) + (5.003 * height) - (6.755 * age);
}
document.write(bmr);
}
like when i push the submit button its suppose to calculate the BMR is not
there is no action
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
I don’t see any code calling the calculateBMR()
function.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.