On entering rate and quantity I want the total amount to be calculated automatically, so I tried the following.
function getAmt()
{
if(isNaN(document.getElementById('<%=TxtRate.ClientID%>').value))
{
alert("Illegal Rate Entered, Please Check It Out.");
document.getElementById('<%=TxtRate.ClientID%>').focus;
return;
}
else if(isNaN(document.getElementById('<%=TxtQty.ClientID%>').value))
{
alert("Illegal Quantity Entered, Please Check It Out.");
document.getElementById('<%=TxtQty.ClientID%>').focus;
return;
}
document.getElementById('<%=TxtAmt.ClientID%>').value=parseFloat
(document.getElementById('<%=TxtRate.ClientID%>').value)*parseFloat
(document.getElementById('<%=TxtQty.ClientID%>').value)
}
Now I created a text box:
<TextBox ID="TxtAmt" runat="server" BorderStyle="Solid" onFocus="getAmt()">
This code is not running.. what am i missing ??
Try it out
Use above code segment when you want to focus the txt amt and once the txtamt is focus your function will calculate the amount value based on the provided rate and quantity..
If you find it useful, please mark it as your answer else let me know…