Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h1>BMI Calculator</h1>
- <!-- Form with button -->
- <form action="">
- <p><input type="button"
- onclick="calc_bmi()"
- value="Calculate BMI" />
- <script type="text/javascript">
- function calc_bmi()
- {
- var weight=(+prompt("Enter weight in pounds: ",""));
- var height=(+prompt("Enter height in inches: ",""));
- var BMI=((weight * 703)/(height * height));
- write_result(height,weight,BMI.toFixed(2));
- }
- </script>
- <script type="text/javascript">
- function write_result(height,weight,bmi)
- {
- var container = document.getElementById("results");
- var results = "<p>Height: " + height + " inches.</p>";
- results += "<p>Weight: " + weight + " pounds.</p>";
- results += "<p>Your BMI is " + bmi + " .</p>";
- container.innerHTML = results;
- }
- </script>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement