Onchanged没相应,为什么?
<meta content= "Microsoft Visual Studio .NET 7.1 " name= "GENERATOR ">
<meta content= "C# " name= "CODE_LANGUAGE ">
<meta content= "JavaScript " name= "vs_defaultClientScript ">
<metacontent= "http://schemas.microsoft.com/intellisense/ie5 "name= "vs_targetSchema ">
<LINK href= "../CSS/MainStyle.css " type= "text/css " rel= "stylesheet ">
<scriptlanguage= "javascript "src= "../JS/OpenWin.js "type= "text/javascript "> </script>
<script language= "javascript ">
function DateCheck()
{
var result;
var a = document.getElementById( "txtTrnQty ").value;
var b = document.getElementById( "txtPrice ").value;
var c= document.getElementById( "txtAmount ").value;
result = a*b;
document.getElementById( "txtAmount ").value=result ;
}
<tr> <td> 数量 </td> <td> <asp:textbox id= "txtPrice " Runat= "server " </asp:textbox> <td> <td> 单价 </td>
<td> <asp:textbox id= "txtPrice "Runat= "server " OnChanged= "DateCheck(); " AutoPostBack=False> </asp:textbox> <td>
<td> 总金额 </td>
<td> <asp:textbox id= "txtAmount "Runat= "server "> </asp:textbox> <td>
</tr>
为什么我输入数量和单价之后不会显示总金额亚?
我这样写为什么不行,这里要实现数量×单价=总金额怎么实现呢?
------解决方案--------------------sf?
------解决方案--------------------试试改成这样:
<asp:textbox id= "txtPrice " Runat= "server " AutoPostBack=False> </asp:textbox>
然后在.cs的Page_Load事件中:
if (!this.IsPostBack)
{
this.txtPrice.Attribute.Add( "onchange ", "DateCheck(); ");
}
------解决方案--------------------觉得应该使用客户端的脚本来操作...
否则和服务器频繁的传来传去,太慢了...
------解决方案-------------------- <td> <asp:textbox id= "txtPrice "Runat= "server " OnChanged= "DateCheck(); " AutoPostBack=False> </asp:textbox> <td>
改为
<td> <asp:textbox id= "txtPrice "Runat= "server " OnChanged= "DateCheck(); " AutoPostBack=True> </asp:textbox> <td>
------解决方案--------------------好久没写过了,不过你的javascript的function没有结束 </script>