![]() ![]() ![]() Then, we have a button and we have given a unique id to this button. Now in the body section of the HTML file, we have two input boxes of type text where the user will enter its height and weight. In the index.js file first, we have included the script.js file so that all the functionality which is written in the JavaScript file is merged to particular elements of HTML. Although we can use the third file of CSS but currently we are ignoring that CSS because we are more focused on the functionality of this calculator instead of styling. We have here two files: the first one id idnex.js and the second one script.js. Let ans= document.querySelector("#result") Īns.innerHTML = "Provide a valid Height!" Īns.innerHTML = "Provide a valid Weight!" Let bmiButton = document.querySelector("#btn") īmiButton. here div section is empty as BMI will be placed here dynamic we are adding the JavaScript file into html code If any input is empty then we will not calculate the BMI and there will be a warning stating that empty fields are not allowed.Īfter entering the values, the user will click the button and his BMI will be displayed on the screen and based on the values of the BMI we can display the message if it is under fat or overfat using simple if else conditions. We will ask the user to enter his weight in the centimeter and also we will ask the user to enter his weight in kilograms. Let’s suppose for a person if weight is W (in kg) and his height is H (in meter) then his BMI will be:įor creating the BMI calculator, we will use HTML, CSS, and JavaScript. It represents the fatness of the body by a numeric value. It is a numeric value which is calculated based on the height and weight of a person. JavaScirpt Tutorial Index JavaScript Tutorial Javascript Example Javascript comment Javascript Variable Javascript Data Types Javascript Operators Javascript If Else Javascript Switch Statement Javascript loop JavaScript Function Javascript Object JavaScript Arrays Javascript String Javascript Date Javascript Math Javascript Number Javascript Dialog Box Javascript Window Object Javascript Document Object Javascript Event Javascript Cookies Javascript getElementByID Javascript Forms Validation Javascript Email Validation Javascript Password Validation Javascript Re-Password Validation Javascript Page Redirect Javascript Print Misc JavaScript P5.js JavaScript Minify JavaScript redirect URL with parameters Javascript Redirect Button JavaScript Ternary Operator JavaScript radio button checked value JavaScript moment date difference Javascript input maxlength JavaScript focus on input Javascript Find Object In Array JavaScript dropdown onchange JavaScript Console log Multiple variables JavaScript Time Picker Demo JavaScript Image resize before upload Functional Programming in JavaScript JavaScript SetTimeout() JavaScript SetInterval() Callback and Callback Hell in JavaScript Array to String in JavaScript Synchronous and Asynchronous in JavaScript Compare two Arrays in JavaScript Encapsulation in JavaScript File Type Validation while Uploading Using JavaScript or jquery Convert ASCII Code to Character in JavaScript Count Character in string in JavaScript Get First Element of Array in JavaScript How to convert array to set in JavaScript How to get current date and time in JavaScript How to Remove Special Characters from a String in JavaScript Number Validation in JavaScript Remove Substring from String in JavaScript Interview Questions JavaScript Interview QuestionsīMI stands for Body Mass Indicator.
0 Comments
Leave a Reply. |