Question: I have a simple conversion form from kg to lbs.

**html**

```
<input type="text" id="kg" name="kg">
<input type="text" id="lbs" name="lbs">

```

I have it setup so that the lbs box updates while you type in the kg box with this code.

**jQuery**

```
$("#kg").keyup(function(){
    $('#lbs').val($('#kg').val()*2.20462);
});

```

How do I get the lbs value to round to 2 decimals places? I am sure it is something fairly simple but all the examples I found online are for if the number is stored in a variable.

Answer: 
use [`toFixed`](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed):

```
$('#lbs').val(($('#kg').val()*2.20462).toFixed(2));

```

---

```
number.toFixed( [digits] )

```

> 
> **Parameter**
> 
> 
> **digits** The number of digits to appear after the decimal point; this
> may be a value between 0 and 20, inclusive, and implementations may
> optionally support a larger range of values. If this argument is
> omitted, it is treated as 0.
> 
> 
> **Returns**
> 
> 
> A string representation of number that does not use exponential
> notation and has exactly digits digits after the decimal place. The
> number is rounded if necessary, and the fractional part is padded with
> zeros if necessary so that it has the specified length. If number is
> greater than 1e+21, this method simply calls Number.toString() and
> returns a string in exponential notation.
> 
> 
>
also this

```
(10.8).toFixed(2); // 10.80

var num = 2.4;
alert(num.toFixed(2)); // 2.40

```

[Formatting a number with exactly two decimals in JavaScript](https://stackoverflow.com/questions/1726630/javascript-formatting-number-with-exactly-two-decimals)