希望哪位能给我一个完整的文本框是关于JAVASCRIPT的,不要只是SCRIPT的文件,要从HTTP大头开始写的。
TheBMI(BodyMassIndex)andIdealWeightarecalculatedusingtheformulas:IdealWeight=Height(c...
The BMI(Body Mass Index) and Ideal Weight are calculated using the formulas:
Ideal Weight= Height(cm) – 100) x 0.9
BMI= weight(kg)/(height (m))^2
Make a java script program which prompts the user input the height in cm and weight in kg, and use
functions to compute and display the Ideal weight and the BMI.
Make another function to show the weight status on an alert box, according to the BMI value.
BMI Value Weight status
Under 18.5 Under weight
18.5 to <25 Normal Weight
25 to < 30 Over Weight
30 and above Obese
Note: You should use ifHelse if Helse statement to show the weight status
效果图 展开
Ideal Weight= Height(cm) – 100) x 0.9
BMI= weight(kg)/(height (m))^2
Make a java script program which prompts the user input the height in cm and weight in kg, and use
functions to compute and display the Ideal weight and the BMI.
Make another function to show the weight status on an alert box, according to the BMI value.
BMI Value Weight status
Under 18.5 Under weight
18.5 to <25 Normal Weight
25 to < 30 Over Weight
30 and above Obese
Note: You should use ifHelse if Helse statement to show the weight status
效果图 展开
2个回答
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=GBK" />
<title>BMI calc</title>
<style type="text/css">
/**
no style
**/
</style>
<script type="text/javascript">
function calc()
{
var IdealWeight=document.getElementById("IdealWeight");
var BMI=document.getElementById("BMI");
var height=document.getElementById("height").value;
var weight=document.getElementById("weight").value;
if(height<5)
{
alert("高度的输入单位是CM,您检查一下是不是输错了,没有小于5CM的人哟!");
}
if(weight>100)
{
alert("重量单位是KG,您检查一下是不是输错了,没有大于100KG的人哟!");
}
IdealWeight.value=(height-100)*0.9;
BMI.value=(weight/(height/100))^2;//^异或操作这边的计算你写的不是太清楚,你自己改下公式。
if(BMI.value<18.5)
{
alert("Your Weight status:Under weight!");
}
else
{
if(BMI.value>=18.5 && BMI<25)
{
alert("Your Weight status:Normal weight!");
}
else if(BMI.value>=25 && BMI<30)
{
alert("Your Weight status:Over weight!");
}
else if(BMI.value>30)
{
alert("above Obese");
}
}
}
</script>
</head>
<body>
<div class="main">
<div class="parInput">
<p><label for="height">Your Height(cm):</label><input type="text" id="height"></input></p>
<p><label for="weight">Your Weight(kg):</label><input type="text" id="weight"></input></p>
<p><input type="button" value="Calculate!" id="calc" onclick="calc()"></input></p>
</div>
<div class="result">
<p><label for="IdealWeight">Your Ideal Weight:</label><input type="text" id="IdealWeight"></input></p>
<p><label for="BMI">Your BMI:</label><input type="text" id="BMI"></input></p>
</div>
</div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=GBK" />
<title>BMI calc</title>
<style type="text/css">
/**
no style
**/
</style>
<script type="text/javascript">
function calc()
{
var IdealWeight=document.getElementById("IdealWeight");
var BMI=document.getElementById("BMI");
var height=document.getElementById("height").value;
var weight=document.getElementById("weight").value;
if(height<5)
{
alert("高度的输入单位是CM,您检查一下是不是输错了,没有小于5CM的人哟!");
}
if(weight>100)
{
alert("重量单位是KG,您检查一下是不是输错了,没有大于100KG的人哟!");
}
IdealWeight.value=(height-100)*0.9;
BMI.value=(weight/(height/100))^2;//^异或操作这边的计算你写的不是太清楚,你自己改下公式。
if(BMI.value<18.5)
{
alert("Your Weight status:Under weight!");
}
else
{
if(BMI.value>=18.5 && BMI<25)
{
alert("Your Weight status:Normal weight!");
}
else if(BMI.value>=25 && BMI<30)
{
alert("Your Weight status:Over weight!");
}
else if(BMI.value>30)
{
alert("above Obese");
}
}
}
</script>
</head>
<body>
<div class="main">
<div class="parInput">
<p><label for="height">Your Height(cm):</label><input type="text" id="height"></input></p>
<p><label for="weight">Your Weight(kg):</label><input type="text" id="weight"></input></p>
<p><input type="button" value="Calculate!" id="calc" onclick="calc()"></input></p>
</div>
<div class="result">
<p><label for="IdealWeight">Your Ideal Weight:</label><input type="text" id="IdealWeight"></input></p>
<p><label for="BMI">Your BMI:</label><input type="text" id="BMI"></input></p>
</div>
</div>
</body>
</html>
2012-01-07
展开全部
文本框不是很简单吗,你可以说清楚点吗
追问
http://zhidao.baidu.com/question/363173345.html?oldq=1#share-anchor
这是我昨天的提问,你看看,就是这样子的。
然后在这个问题里我已经贴出效果图了,
外加一张例子
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询