jalajakshi p

jalajakshi p

  • NA
  • 12
  • 0

Adding two money field values in javascript

Apr 8 2009 1:58 AM

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.


Answers (4)