I have following JavaScript function to make some calculation with textboxes but when I call this function on textbox the it doesn’t works. Here is my JS code
Update
<script type="text/javascript" language=javascript>
function calc()
{
var pkrusd;
var pkrusd = parseFloat(document.getElementById("<%=txtpkrusd.ClientID %>").value, 10);
var ratelb;
ratelb = parseFloat(document.getElementById("<%=txtRatelb .ClientID %>").value, 10);
var res;
res = parseFloat(document.getElementById("<%=txtF5.ClientID %>").value, 10);
res=pkrusd*ratelb;
}
</script>
<asp:TextBox ID="txtpkrusd" runat="server" BackColor="Yellow" style="text-align:right" onkeyup="calc()"></asp:TextBox>
<asp:TextBox ID="txtRatelb" runat="server" BackColor="Yellow" Style="text-align: right" onkeyup="calc()"></asp:TextBox>
Please any one help me to find that what exactly i am missin in the code.
Your variables aren’t numbers. They are strings, so addition just concatenates them together.
Cast them to integers:
Or floats: