用javascript中function函数写正方形面积?
用javascript中function函数写正方形面积?只能用javavscript来写,不能用html代码写...
用javascript中function函数写正方形面积?
只能用javav script来写,不能用html代码写 展开
只能用javav script来写,不能用html代码写 展开
2个回答
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>求正方形面积</title>
<script type="text/javascript" language="javascript">
function getAcreage(){
var sideLength=parseFloat(document.getElementById("side").value);
document.getElementById("acreage").value=sideLength*sideLength;
}
</script>
</head>
<body>
<table border="0">
<tr>
<td>正方形边长:</td>
<td><input type="text" id="side" name="side"/></td>
</tr>
<tr>
<td>正方形面积:</td>
<td><input type="text" id="acreage" name="acreage" readonly="readonly"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" id="calc" name="calc" value="计算" onclick="getAcreage()"/></td>
</tr>
</table>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>求正方形面积</title>
<script type="text/javascript" language="javascript">
function getAcreage(){
var sideLength=parseFloat(document.getElementById("side").value);
document.getElementById("acreage").value=sideLength*sideLength;
}
</script>
</head>
<body>
<table border="0">
<tr>
<td>正方形边长:</td>
<td><input type="text" id="side" name="side"/></td>
</tr>
<tr>
<td>正方形面积:</td>
<td><input type="text" id="acreage" name="acreage" readonly="readonly"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" id="calc" name="calc" value="计算" onclick="getAcreage()"/></td>
</tr>
</table>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询