Randy Webb wrote:[color=blue]
> Jerry Park wrote:
>[color=green]
>> Phill Long wrote:
>>[color=darkred]
>>> Right, ok, well I have designed a form that will display a price
>>> (22.34) in
>>> a text box, and another price in the other text box... I also have a
>>> blank
>>> text box... Now I want to add both the prices together and get a
>>> total in
>>> the bloank textbox..
>>> I got this example off a website sumwhere.. But it does not display the
>>> decimal number, it only displays the whole number
>>>
>>> PLEASE HELP
>>>
>>> var number1 = parseInt(document.forms[0].CasesSellingPrice.value);
>>> var number2 = parseInt(document.forms[0].AccessoriesSellingPrice.value);
>>> document.forms[0].total.value = number1 + number2;
>>>
>>>[/color]
>> This link might help:
>>
http://www.aptools.com/javascript/[/color]
>
>
> I found it funny actually. Without going through the entire script (its
> inherently long), lets go through the first 5 or 6 significant lines:
>
>
> <script language="javascript">
>
> Should be type="text/javascript", but since it appears to have been last
> modified in 2001, its not relevant.
>
> <!-- Hide from browsers without javascript.
>
> Nor is the HTML comment entity needed. I guess if you browse with a 10
> year old browser it might be needed.
>
> function FormatNumber(Number,Decimals,Separator)
> {
>
> Not sure that I would want a variable (parameter) named Number.
> NumToFormat seems better and more intuitive.
>
> // ************************************************** ********
> // Placed in the public domain by Affordable Production Tools
> // March 21, 1998
> // Web site:
http://www.aptools.com/
> //
> // November 24, 1998 -- Error which allowed a null value
> // to remain null fixed. Now forces value to 0.
> //
> // October 28, 2001 -- Modified to provide leading 0 for fractional number
> // less than 1.
> //
> // This function accepts a number to format and number
> // specifying the number of decimal places to format to. May
> // optionally use a separator other than '.' if specified.
> //
> // If no decimals are specified, the function defaults to
> // two decimal places. If no number is passed, the function
> // defaults to 0. Decimal separator defaults to '.' .
> //
> // If the number passed is too large to format as a decimal
> // number (e.g.: 1.23e+25), or if the conversion process
> // results in such a number, the original number is returned
> // unchanged.
> // ************************************************** ********
> Number += "" // Force argument to string.
> Decimals += "" // Force argument to string.
> Separator += "" // Force argument to string.
>
> Decimals = Decimals.toString() perhaps? Might be buggy though, I don't
> remember.
>
>
>
http://www.jibbering.com/faq/#FAQ4_6
>
> Seems to be a heck of a lot shorter (although it lacks some of the
> functionality in the above) and a lot easier to follow.
>
> None of which answers/addresses the OP's original problem. See my
> previous reply in this thread.
>[/color]
Thanks for the comments. Yes, it was written for older browsers, but
still works for current browsers. There are still a lot of older
browsers around ...
It was written as a drop in library. Doesn't really matter if some other
code is simpler so long as it works.
Don't know what the name of a parameter should matter ...