日期:2014-05-16 浏览次数:20366 次
<script type="text/javascript">
function tiJiao(){
var id_td1 = document.getElementById("td1");
var id_td2 = document.getElementById("td2");
var id_td3 = document.getElementById("td3");
id_td3.innerHTML =id_td1.innerHTML * id_td2.innerHTML;
}
function add(id)
{
var row = id.insertRow(id.rows.length);
var col = row.insertCell(0);
col.innerHTML = " ";
var col = row.insertCell(1);
col.innerHTML = " ";
col = row.insertCell(2);
col.innerHTML = " ";
}
</script>
<table border="1" id="tbid">
<tr>
<td width="100px;">单价</td>
<td width="100px;">数量</td>
<td width="100px;">总额</td>
</tr>
<tr>
<td id="td1">12</td>
<td id="td2">34</td>
<td id="td3"></td>
</tr>
</table>
<input type="button" onClick="tiJiao()" value="计算">
<input type="button" onClick="add(tbid)" value="增加行">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<table width="80%" border="1" align="center" id="test">
<tr>
<td width="69">列值</td>
<td width="69">整数一</td>
<td width="69">整数二</td>
<td width="54">总和</td>
</tr>
<tr>
<td>1</td>
<td><input type="text" name="textfield" onchange="count(this)"></td>
<td><input type="text" name="textfield3" onchange="count(this)"></td>
<td><input type="text" name="textfield5" disabled></td>
</tr>
<tr>
<td>2</td>
<td><input type="text" name="textfield2" onchange="count(this)"></td>
<td><input type="text" name="textfield4" onchange="count(this)"></td>
<td><input&n