Cool... I did find a CFX tag on the Alliare web site to do this...

CFX_NUMBER2TEXT

Has more functionality than I needed but it's working...:)

thanks
Jay

-----Original Message-----
From: Bryan LaPlante [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 30, 2001 11:49 AM
To: CF-Talk
Subject: Re: Numbers to Text


This may not be what you are looking for, but I wrote a little check writer
script for a bank once that translated the number column into dollars and
cents as words on the client machine. This script was written pre IE4 before
you could declair an array object by reference. All that the first function
does is declaire the array object for moneyobj, the rest of the script does
the work when you pass it a float or decimal number.

-- script --
function moneyObj()
{
for (i = 0; i<moneyObj.arguments.length; i++)
 this[i] = moneyObj.arguments[i];
}
teen = new
moneyObj("Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","
Seventeen","Eighteen","Ninteen");
ten  = new
moneyObj("","","Twenty","Thirty","Fourty","Fifty","Sixty","Seventy","Eighty"
,"Ninty");
one  =  new
moneyObj("","One","Two","Three","Four","Five","Six","Seven","Eight","Nine");



function checkWrite(s)
{
var moneyString = '0123456789';
var money  = '';
var printMoney = '';
for (i = 0; i <= s.length; i++)
 {
 g = s.charAt(i);
 if (moneyString.indexOf(g) != -1)money += g;
 }

var dollars  = money.substring(0,(money.length) -2);
var cents  = money.substring(dollars.length,money.length);

while (cents.length < 2)
  {
  cents = 0 + cents;
  }
while (dollars.length < 6)
  {
  dollars = 0 + dollars;
  }

var ones  = dollars.charAt(0);
var tens  = dollars.charAt(1);
var hundreds = dollars.charAt(2);
var thousands = dollars.charAt(3);
var Tthousands = dollars.charAt(4);
var Hthousands = dollars.charAt(5);


if (ones != 0)
 {
 printMoney = one[ones] + ' hundred ';
 }
 else
  {
  printMoney = '';
 }
if ((tens + hundreds) < 1)
 {
 printMoney += '';
 }
if ((tens + hundreds) < 1 && ((hundreds + thousands) < 1 && ((thousands +
Tthousands) < 1)))
 {
 printMoney += ' thousand ';
 }
if ((tens + hundreds) > 0 && ((tens + hundreds) <= 9))
 {
 printMoney += one[hundreds] + ' thousand ';
 }
if ((tens + hundreds) > 9 && ((tens + hundreds) <= 19))
 {
 printMoney += teen[hundreds] + ' thousand ';
 }
if ((tens + hundreds) > 19 && ((tens + hundreds) < 100))
 {
 printMoney += ten[tens] + ' ' + one[hundreds] + ' thousand ';
 }

if (thousands != 0)
 {
 printMoney += one[thousands] + ' hundred ';
 }
 else
  {
  printMoney += '';
 }
if ((Tthousands + Hthousands) > 0 && ((Tthousands + Hthousands) <= 9))
 {
 printMoney += one[Hthousands];
 }
if ((Tthousands + Hthousands) > 9 && ((Tthousands + Hthousands) <= 19))
 {
 printMoney += teen[Hthousands];
 }
if ((Tthousands + Hthousands) > 19 && ((Tthousands + Hthousands) < 100))
 {
 printMoney += ten[Tthousands] + ' ' + one[Hthousands];
 }

var UppCase = printMoney.charAt(0);
var LowCase = printMoney.substring(1,printMoney.length);

 document.forms[0].dollarString.value = '' + printMoney + ' and ' + cents  +
'\/ 100';
 document.write(UppCase + LowCase.toLowerCase() + ' and ' + cents  + '\/
100');
}
-- End Script --
----- Original Message -----
From: "Jay Wigginton" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, March 30, 2001 10:20 AM
Subject: Numbers to Text


> Anyone know of a custom tag available or a means within CF to convert
> numbers to text... 2 to two, 100 to one hundred, etc.?
>
> thanks
> Jay
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to