You are here: Re: number formats and posted data « PHP Language « IT news, forums, messages
Re: number formats and posted data

Posted by -Lost on 12/23/06 03:39

> "Ric" <antispam@randometry.com> wrote in message
> news:emhntf$dk$1@online.de...
>> nostabo schrieb:
>> > Hi all,
>> >
>> > I have been trying to display numbers (actually money amounts) on an
> HTML
>> > form in text type input boxes and then use the posted values in
> calculations
>> > using PHP. The problem is that I can accept inputted values from a text
> box
>> > when entered in the 1000 or 1000.00, but when a users adds a comma the
> value
>> > (for example 1,000.00) the value is displayed as 1.0 by the
> number_format
>> > function (see my code below)
>> >
>> > <input type='text' id='software' name='software' value='<?php print
>> > number_format($_POST['software'], 2);?>' >
>>
>> this shoudl do it:
>>
>> number_format($_POST['software'], 3)

"nostabo" <nostabo@microsoft.com> wrote in message
news:x9Gdnd76rqcZ8hHYnZ2dnUVZ_s-rnZ2d@comcast.com...
> Thank you, but this simply adds another decimal place to the truncated
> value.
> 1.000 instead of 1.00
>
> Rick

Yeah, I was not quite sure of that either. It truncates any number to its first number
and three decimal 0s.

1,000,000 becomes 1.000

123,456 becomes 1.000

645,321 becomes 6.000

I guess it is not worse than stripping the commas and replacing them with pipes (|),
something I recently had to do in this wonky financial application. Nothing like seeing:

123|456|789:123

....to make you sick of numbers quick.

> Ric said:
> 1,35 will show up as 135, not sure if that is what you want:-)

French decimals... ugh. : P

-Lost

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация