实例程序
<!DOCTYPE html>
<html><head>
<meta charset="UTF-8">
<title>java上机题目</title>
<style type="text/css">
#foot{
background-color: yellow;
}
caption{
font-style: italic;
font-size: 15px;
}
</style>
<script language="JavaScript" type="text/javascript">
function $(a)
{
var $b=document.getElementById(a);
return $b;
}
function myFunction()
{
$("34").innerHTML=((parseFloat($("33").value)+parseFloat($("32").value))/2);
$("44").innerHTML=((parseFloat($("43").value)+parseFloat($("42").value))/2);
$("52").innerHTML=((parseFloat($("32").value)+parseFloat($("42").value))/2);
$("53").innerHTML=((parseFloat($("43").value)+parseFloat($("33").value))/2);
$("54").innerHTML=((parseFloat($("44").innerHTML)+parseFloat($("34").innerHTML))/2);
}
</script>
</head>
<body>
<table border="1" cellpadding="1">
<caption>组合表格</caption>
<tr>
<th rowspan="2"></th>
<th colspan="2" >Points</th>
<th rowspan="2">Personal Average</th>
</tr>
<tr>
<th>Test1</th>
<th>Test2</th>
</tr>
<tr>
<th>English</th>
<td ><input type="text" size="20px" id="32"value=""></td>
<td ><input type="text" size="20px" id="33" value=""></td>
<td id="34"></td>
</tr>
<tr>
<th>Math</th>
<td ><input type="text" size="20px" id="42" value=""></td>
<td ><input type="text" size="20px" id="43" value=""></td>
<td id="44"></td>
</tr>
<tr id="foot">
<th>Average</th>
<td id="52"></td>
<td id="53"></td>
<td id="54"></td>
</tr>
</table>
<input type="button" οnclick="myFunction()" value="计算">
</body>
</html>