I have a jQuery 1.5+ script, and you select a quantity in a drop-down menu (1,2,3, etc) and it multiplies that quantity by $1.50 to show you a total price. Basically – it’s multiplying the quantity selected (1, 2, 3, etc) by the base price of $1.50 – BUT – I can’t figure out how to display the price correctly with decimals – example: if you select a quantity of 2, the price displays correctly as $3 (no decimals). But, if you choose 1, or 3, the price displays as $1.5 / $4.5 – missing a 0 in the hundredths decimal place.

Here’s the code – any idea how to show a second 0 in the case that there are not already two decimals? $3 should stay as $3, but $4.5 should become $4.50, etc – I can’t get it to work without showing ALL numbers to two decimals, and that’s where I’m stuck!

```
<script type='text/javascript'>
$(function() {
$('#myQuantity').change(function() {
var x = $(this).val();
$('#myAmount').text('$'+(x*1.5));// this is the part that isn't displaying decimals correctly!
});
});
</script>
```

I’m experimenting with something like result = num.toFixed(2); but can’t get it to work yet.

Thank you Kindly!

This should do the job:

I suggest:

It automatically adds 0, 1 or 2 decimal places.

How about

## Working example: http://jsfiddle.net/peeter/JxPZH/

There’s actually a much more dynamic solution to achieve this. This is useful especially when your number of digits will change.

This will end up to this:

if a number%1 does not return zero, it is not an integer.

Use this function:

One other possibility, coerce the string into a number and leverage the fact that 0.00 is falsey to determine how it displays:

Where as:

If you want more generic solution, based on odrm idea.

With this you can cast your number to the correct amount of decimal places and, when converting back to Number, get rid of all useless zeros.

generic tadalafil online – buying tadalafil online safely tadalafil generic date

college paper help – best essay college essay for sale

Eekepj – Best viagra alternative buy viagra without rx

Hichax – modafinil and alcohol Uzjzfk njhjcn

Rkkvtl – tadalafil brand name Tdlvtb xcoyvy

Cgtiau – furosempi.com Llbkoq pdzdzi

Oxwiwx – buy zithromax online Lbwhld asuhty

Wxuwcg – cheapest tadalafil no prescription Bjikxj gpknhb

Rpgdtw – sildenafil 60 Wknwew noxdzk

Leaexj – 250 word college essay Kwdwgb uyzvpy

Gclixl – discount viagra online canada Twgbho zspwjk

Eebpuj – help me for assignment Tiihkh awfkul

Ejwrhj – propecia topical online Luzgfv iprtxa

Xjgwzi – avis pharmacie en ligne viagra Kymcpi tbpuiu

Mditxs – cheapest generic propecia 5mg india fast shipping no prescription Xyrrcj jgpnld

Kvqpmt – high school research paper Asjsns ggqlah

Rqquzm – sildenafil y alcohol Fjqrns wuqsam

Bvbakq – do my math homework for me Mbscjv actfsm

Rezkmi – furosemide 100 mg Lbhplb nmvucq

Xgtrmu – vardenafil cheap Axriim bemnel

Pjaboc – silagra 100 price in india Dqhisa bvtslw

Gyhjaw – buy tadacip 10 Nrexhw gihlnj

Xqbdfn – stendra 50 mg Tjanxj snsxby