output标签

output

output 标签定义不同类型的输出,比如脚本的输出。例如:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chapter3</title>
<style type="text/css">
label{
	display: inline-block;
	width: 60px;
}
</style>
<script type="text/javascript">
function CalculateBMI(feet,inches,pounds,resultElementName){
	inches=Number(inches)
	pounds=Number(pounds)
	feet=Number(feet)

	var totalInches=(feet*12)+inches
	var resultElement=document.getElementById(resultElementName)
	resultElement.innerHTML=Math.round(pounds*703*10/totalInches/totalInches)/10
}
</script>
</head>

<body>

<h1>Body Mass Index Calculator</h1>

<form action="#" id="bmiCalculator">

<label for="feet inches ">Height:</label>

<input name="feet">feet<br>

<label></label>

<input name="inches">inches<br>

<label for="pounds">Weight:</label>

<input name="pounds">pounds<br><br>

<input type="button" name="calc" value="Calculate" onclick="CalculateBMI(this.form.feet.value,this.form.inches.value,this.form.pounds.value,'result')">

</form>

<p>Your BMI:<output id="result"></output></p>

<table cellpadding="5" cellspacing="0" border="1">
<tr>
   <td><b>BMI</b></td>
   <td><b>Weight Status</b></td>
 </tr>
 <tr>
   <td>Below 18.5</td>
   <td>Underweight</td>
 </tr>
 <tr>
   <td>18.5 &#8211; 24.9</td>
   <td>Normal</td>
 </tr>
 <tr>
   <td>25.0 &#8211; 29.9</td>
   <td>Overweight</td>
 </tr>
 <tr>
   <td>30.0 and Above</td>
   <td>Obese</td>
 </tr>

</table>
</body>
</html>

HTML output 标签

posted @ 2015-03-21 15:16  健达  阅读(367)  评论(0编辑  收藏  举报