BMI计算器
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
}
body{
font-size: 63%;
}
.clearfix:after{
content:'';
display: block;
clear:both;
}
.clearfix{
zoom:1;
}
.bmi-box{
width:302px;
}
.bmi-box input{
width:150px;
}
.cueBox{
font-size: 1.6em;
/* line-height: 180%; */
text-align: left;
margin: 5px 0px;
padding: 0px;
}
#cue{
border: 1px dotted #ddd;
background-color: #ffa;
margin: 10px 0px 15px 0px;
padding: 2px;
}
.tit{
width:120px;
height: 2.4em;
font-size: 1.4em;
/* line-height: 180%; */
float:left;
}
.msg input{
width:170px;
padding-left:10px;
background: #eff8ff;
border: 1px solid #999;
font-size: 1.2em;
line-height: 1.6em;
float:left;
}
.button{
padding: 2px 10px;
font-size: 1.0em;
line-height: 100%;
margin:0 auto;
}
.msg{
width:100%;
}
</style>
</head>
<head>
<script>
function idealweight(a){
var x=(a-100)*0.9;
return x;
}
function bmi(a,b){
var bmi=b*1.0/((a*1.0/100)*(a*1.0/100));
return bmi;
}
function Cal(form){
var a=eval(form.height.value);
var b=eval(form.weight.value);
var BMI=eval(form.BMI.value);
form.IW.value=idealweight(a);
form.BMI.value=bmi(a,b);
disp_alert(bmi(a,b));
}
function disp_alert(bmi){
if (bmi < 18.5)
{
document.getElementById('cueBox').style.display='block';
document.getElementById('cue').innerHTML="你的体重太轻,要多吃点哟!";
// alert("你的体重太轻,要多吃点哟!");
}
else if (bmi >= 18.5 && bmi < 25)
{
////////////////////////////////
// alert("亲,你的体重正常,要继续保持哟!"); //
////////////////////////////////
document.getElementById('cueBox').style.display='block';
document.getElementById('cue').innerHTML="亲,你的体重正常,要继续保持哟!";
}
else if (bmi >= 25 && bmi< 30)
{
document.getElementById('cueBox').style.display='block';
document.getElementById('cue').innerHTML="亲,您的体重过重,要减肥了!";
//////////////////////////////
// alert("亲,您的体重过重,要减肥了!"); //
//////////////////////////////
}
else
{
document.getElementById('cueBox').style.display='block';
document.getElementById('cue').innerHTML="亲,你确实要减肥了!";
//////////////////////////
// alert("亲,你确实要减肥了!"); //
//////////////////////////
}
}
</script>
</head>
<body>
<form method=post class="bmi-box">
<div class="msg clearfix">
<p class="tit">你的身高(cm):</p><input type="text" name="height">
</div>
<div class="msg clearfix">
<p class="tit">你的体重(kg):</p><input type="text" name="weight">
</div>
<div class="clearfix">
<p class="tit"></p>
<input type="button" class="button" value="开始计算" onclick="Cal(this.form)">
</div>
<div class="cueBox" id="cueBox" style="display:none;">
<div id="cue"></div>
</div>
<div class="msg clearfix">
<p class="tit">你的理想体重(kg):</p><input type="text" name="IW">
</div>
<div class="msg clearfix">
<p class="tit">您的BMI值:</p><input type="text" name="BMI">
</div>
</form>
</body>
</html>
BMI计算器的更多相关文章
- Angular 2.0 从0到1:Rx--隐藏在Angular 2.x中利剑
第一节:Angular 2.0 从0到1 (一)第二节:Angular 2.0 从0到1 (二)第三节:Angular 2.0 从0到1 (三)第四节:Angular 2.0 从0到1 (四)第五节: ...
- start running 开始跑步减肥
begin 两个月前,逛超市的时候站在体重秤上称了称,一直以为自己体重很正常(BMI<25,虽然也不轻~~~),结果直接迈过超重,奔着肥胖跑去了(BMI>30,BMI计算器 http:// ...
- WEBBASE篇: 第八篇, JavaScript知识2
JavaScript 2 一,数据类型: 作用: 约束了数据在内存中所占空间大小问题的: JS数据类型分类: 基本数据类型(值类型) (1) number 类型: 数字类型,可以表示32位的整数或64 ...
- JS&jQuery
1.JavaScript概述 1.什么是JavaScript JavaScript简称JS,是一种专门运行于JS解释器/引擎中的解释型脚本语言 2.JS发展史 ...
- 【Python】BMI指数 计算器
身体质量指数 (Body Mass Index, 简称BMI), 亦称克托莱指数, 是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准.BMI 值超标,意味着你必须减肥了. 在线版:https: ...
- 1.C#WinForm基础制作简单计算器
利用c#语言编写简单计算器: 核心知识点: MessageBox.Show(Convert.ToString(comboBox1.SelectedIndex));//下拉序号 MessageBox.S ...
- 自己动手写计算器v1.1
这个改动主要是使用工厂模式替代了简单工厂模式,这样做的好处是如果以后我们要扩充其他运算时,就不用总是去修改工厂类, 这是可以采取工厂模式,主要是将原来简单工厂类的逻辑判断分离出来,将它作为一个借口,与 ...
- 自己动手写计算器v1.0
今天突发奇想,想着看了还几个设计模式了,倒不如写点东西来实践它们.发现计算器这种就比较合适,打算随着设计模式的学习,会对计算器不断的做改进. 包括功能的增加和算法的改进.初学者难免犯错,希望大家不吝指 ...
- 【IOS开发笔记03-视图相关】简单计算器的实现
UIView 经过前几天的快速学习,我们初步了解的IOS开发的一些知识,中间因为拉的太急,忽略了很多基础知识点,这些知识点单独拿出来学习太过枯燥,我们在今后的项目中再逐步补齐,今天我们来学习APP视图 ...
随机推荐
- @component的注解
1.@controller 控制器(注入服务) 2.@service 服务(注入dao) 3.@repository dao(实现dao访问) 4.@component (把普通pojo实例化到spr ...
- bzoj 3657 斐波那契数列(fib.cpp/pas/c/in/out)
空间 512M 时限2s [题目描述] 有n个大于1的正整数a1,a2,…,an,我们知道斐波那契数列的递推式是f(i)=f(i-1)+f(i-2),现在我们修改这个递推式变为f(i)=f(i-1) ...
- Mybatis <if>标签使用注意事项
在<if>标签的test中,不能写成“name !='aa'” , 会报错### Error querying database. Cause: java.lang.NumberForma ...
- PHP 根据IP地址获取所在城市
header('Content-Type:text/html;Charset=utf-8'); function GetIp(){ $realip = ''; $unknown = 'unknown' ...
- 解决node-sass安装不了的问题
1.下载https://github.com/sass/node-sass-binaries/blob/master/win32-x64-48_binding.node到E:\primeng\lib目 ...
- POJ - 3169 差分约束
题意:n头牛,按照编号从左到右排列,两头牛可能在一起,接着有一些关系表示第a头牛与第b头牛相隔最多与最少的距离,最后求出第一头牛与最后一头牛的最大距离是多少,如 果最大距离无限大则输出 ...
- 修改主机hosts文件 访问外网
参考:详解google Chrome浏览器(理论篇) 感谢原博主 Alan_beijing 的分享,博客:Alan_beijing hosts文件所在位置: a.Windows系统: C:\Windo ...
- MySQL表锁和行锁
锁粒度 MySQL 不同的存储引擎支持不同的锁机制,所有的存储引擎都以自己的方式显现了锁机制,服务器层完全不了解存储引擎中的锁实现: InnoDB 存储引擎既支持行级锁(row-level locki ...
- 大小堆C++实现
C++大小堆实现(仿函数) 具体代码如下 #pragma once #include<iostream> #include<vector> using namespace st ...
- underscore || lodash
1.http://www.css88.com/archives/5443 (underscore) let list = _.filter(record.orderGoodsList, item =& ...