Javascript运行时错误:'calcAmt'未定义 [英] Javascript runtime error: 'calcAmt' not defined

查看:153
本文介绍了Javascript运行时错误:'calcAmt'未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的代码



< html>

< head>



following is my code

<html>
<head>

function calcAmnt() 
var text1 = document.getElementById('<%= txt_qty_OS.ClientID %>');
var text2 = document.getElementById('<%= txt_rate_OS.ClientID %>');
var txt_amnt = document.getElementById('<%= txt_amt_OS.ClientID %>');

                                           if (text1.value.length == 0) {
                                               text1.value = 0;
                                           }

                                           if (text2.value.length == 0) {
                                               text2.value = 0;
                                           }
                                           var x = parseFloat(text1.value);
                                           var y = parseFloat(text2.value);

                                           txt_amnt.value = x * y;
                                           if (txt_amnt.value == "NaN")
                                               txt_amnt.value = 0;
                                       }





< / head>



< ; body>





</head>

<body>

<table class="sTable">
<tr>
<td class="sTD_R">
Quantity:
   </td>
 <td>
<asp:TextBox ID="txt_Qty_OS" runat="server" Height="20px" onChange ="calcAmt()" width="167px">0</asp:TextBox>
</td>
</tr>
<tr>
<td class="sTD_R">
Rate:
</td>
<td>
<asp:TextBox ID="TXT_RATE_OS" runat="server" Height="20px" OnChange ="calcAmt()" width="167px">0</asp:TextBox>
</td>
</tr>
<tr>
<td class="sTD_R">
Amount:
</td>
<td>
<asp:TextBox ID="TXT_AMT_OS" runat="server"Class="textbox" Height="22px" Width="165px">0</asp:TextBox>
</td>
</tr>
</table>





< / body>

< / html>



代码中的错误是什么?

提前提前...



</body>
</html>

what is the error in code???
thanx in advance....

推荐答案

这是因为你的函数没有命名为calcAmt ,它被命名为calcAmnt。错误告诉你它找不到任何名为calcAmt的东西。
This is because your function is not named calcAmt, it is named calcAmnt. The error is telling you it can''t find anything named calcAmt.


这篇关于Javascript运行时错误:'calcAmt'未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆