Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
following is my code

<html>
<head>

C#
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>

XML
<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>

what is the error in code???
thanx in advance....
Posted
Updated 21-May-13 4:30am
v2

1 solution

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.
 
Share this answer
 
Comments
jagdish123061 21-May-13 10:32am    
I changed it to calcAmt but same error calcAmt is not defined...
ZurdoDev 21-May-13 10:34am    
You need to post the rest of the code. Is your function inside a script block?
Sergey Alexandrovich Kryukov 21-May-13 12:38pm    
Ha-ha, that's a catch, a 5.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900