<script type="text/javascript">
function Sumtxt(obj)
{
var strtxt1 =obj.value;
var objtxt3 = document.getElementById("txtTotal");
var tot=parseInt(objtxt3.value);
tot += parseInt(strtxt1);
objtxt3.value=tot;
}
</script>
HTML代码:
<asp:TextBox ID="txtArea" runat="server" Width="40px" onblur="Sumtxt(this)"></asp:TextBox>
<asp:TextBox ID="txtTotal" runat="server" Width="40px" Text="0"></asp:TextBox>
对每一个textbox控件添加:onblur="Sumtxt(this)",在结果文本框中初始化数字‘0’