Hi,
I have three textboxes and button.User enters values in two text like
TextBox1: 111111111111111.1111
TextBox2:1111.1111
when user clicks button then in javascript I need to calculate sum of these two values and I should display in TextBox3.
I have tried with following code
var
txt1 = parseFloat(document.getElementById('TextBox1').value); var txt2 = parseFloat(document.getElementById('TextBox2').value); var document.getElementById('TextBox3').value = txt1 + txt2;Result value I am getting is 111111111112222.22.
But I want the result with 4 decimal places and it should not be rounded.
jalajakshi pPosted Apr 17, 2009, 6:40 AM
I know it is taking only 111111111111111.11
but I want to add these two values with 4 decimal places only.I dont want to round it up.
Thanks,
Jalajakshi
aru vPosted Apr 9, 2009, 7:43 AM
Hi,
In java script after parsing "111111111111111.1111" to float its converted to "111111111111111.11".
Thts the actual problem.
What is the maximum value of float in Java script?
Thanks,
Aru
jalajakshi pPosted Apr 9, 2009, 7:00 AM
Hi Satish,
I tried in the same way.It works for only the values which are having 13 digits whole number with 4 decimal values .
But I want answer for 15 digits whole number with 4 decimal digits as I have shown in my example.
ie for Text1-111111111111111.1111
Text2-111.1111
and I want result Text3 as 111111111111222.2222
satish kumarPosted Apr 9, 2009, 6:17 AM
hi jalajakshi ,
i tried ur solution i got it just check onces.
<
script language="javascript"> function f1(){
var t1=parseFloat(document.getElementById('<%=TextBox1.ClientID %>').value);alert(t1);
var t2=parseFloat(document.getElementById('<%=TextBox2.ClientID %>').value);alert(t2);
var t3=document.getElementById('<%=TextBox3.ClientID %>');t3.value=t1+t2;
alert(t3);
}
script><
asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="f1()" />after that give me responce.
regards,
satish kumar