if you mean to do it on the client side, see the following example<form>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td>unit price</td><td>quantity</td><td>price</td>
</tr>
<tr>
<td><input name=txt1 onchange="calcPrice()"></td>
<td><input name=txt2 onchange="calcPrice()"></td>
<td><input name=txt3></td>
</tr>
<tr>
<td><input name=txt1 onchange="calcPrice()"></td>
<td><input name=txt2 onchange="calcPrice()"></td>
<td><input name=txt3></td>
</tr>
</table>
</form>
<script language="javascript">
function parseValue(s)
{
if (isNaN(s) || s == "")
return 0;
else
return parseFloat(s);
}function calcPrice()
{
var e = event.srcElement;
var tr = e.parentNode.parentNode;
var inputs = tr.all.tags("INPUT");
var unitprice = parseValue(inputs[0].value);
var quantity = parseValue(inputs[1].value);
inputs[2].value = unitprice * quantity;
}
</script>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td>unit price</td><td>quantity</td><td>price</td>
</tr>
<tr>
<td><input name=txt1 onchange="calcPrice()"></td>
<td><input name=txt2 onchange="calcPrice()"></td>
<td><input name=txt3></td>
</tr>
<tr>
<td><input name=txt1 onchange="calcPrice()"></td>
<td><input name=txt2 onchange="calcPrice()"></td>
<td><input name=txt3></td>
</tr>
</table>
</form>
<script language="javascript">
function parseValue(s)
{
if (isNaN(s) || s == "")
return 0;
else
return parseFloat(s);
}function calcPrice()
{
var e = event.srcElement;
var tr = e.parentNode.parentNode;
var inputs = tr.all.tags("INPUT");
var unitprice = parseValue(inputs[0].value);
var quantity = parseValue(inputs[1].value);
inputs[2].value = unitprice * quantity;
}
</script>
解决方案 »
- 网站上传到服务器,在IE6下不支持ajax控件,什么原因?急!!!
- asp.net页面能否实现像windows桌面那样的分级菜单效果?
- vs2005 team suite能不能安装vs2005 sp1?
- 各位帮帮忙,重新发帖!!!谢谢各位了,小弟再次先拜了
- Ext gridpanel 加载数据问题 急!
- ============如何产生6位随机数,不重复!
- 如何为 RadioButtonList 添加响应脚本
- 请教一个小小的JavaScript问题
- 如何查询从textbox.text得到的关键字?
- 高高高高,难度太大(谁会)!在DATAGRID中选定多行!谢谢!
- 在一个DataGrid,如何把用"属性生成器"生成的“删除”列放在最后一列。
- 在win2000中使用vs.net2003不能创建asp.net的程序?
关于DataGrid的.