I can't format the total price!!

greenspun.com : LUSENET : S-Mart Shopping Cart : One Thread

After responding my last question about this matter, i implement the sugestions made by James L. Farmer (jim@team-blankets.com), and I still have the prices showing with with to decimals when it end with an zero.

Example:

the HTML resulting page appear like this:

Produto Prego Unit. Quant. Prego Total L'Histoire de l'Aviation 10.650$ 1 10.65$ Total da Encomenda 10.65$

Thanks in advance

-- Manuel Tavares (mar114@hotmail.com), September 07, 1999

Answers

Hi,

Here is the fix.

sub pad { my $number = shift; if (index($number,".") >= 0) { my($left,$right) = split(/\./,$number); if (length($right) == 0) { $number = $number . "000"; } elsif (length($right) == 1) { $number = $number . "00"; } elsif (length($right) == 2) { $number = $number . "0"; }

} else { $number = $number . ".000"; } return $number; }

That should do it let me know.

Jim

-- James L. Farmer (Jin@team-blankets.com), September 07, 1999.


Moderation questions? read the FAQ