PDA

View Full Version : Text field formatting


xperimental
02-12-2001, 06:22 PM
I have a calculator I am building in flash and want to format the input boxes to the following format:

user input: 2300000
return: 23,000.00 ---> I wnat all fields to follow this formating rule regardless of what they enter.

So

two intergers from the right insert decimal, and for every three intergers from the decimal insert a comma.

It is a calculator and it needs to be able to perform mathamatical equations.

thanks.

Xperimental.

Jesse
02-12-2001, 11:50 PM
That would mean you'd have to actually calculate based on other varaibles. If the user enters 123450 and you format it to 1,234.50 you're not going to be able to us that variable in a mathermatical equation any more coz it has non-numerical characters in it.

But if you still want to do it you can use length() and substring. As a matter of fact, if you checkout Flashguru's Function Library int he tutorials section you could use that. Convert the data to an array, then use his reverse array. Then insert values from left to right (which will be easier using substring() ) then reverse the array again....

It's not going to be too dificult, so you try scripting it first. If you can't, I'll help out.

Cheers

Jesse

xperimental
02-13-2001, 12:45 AM
Thanks for the reply,

The hardest part is the ",". And as of this second I've gotten kinda lost with what you said. But I'll do some digging.
My script so far is working fine, a lot of variables are being passed around, and the "." works alright with an equation, it's just the blessed "," that messes it up.
We'll see how it goes,and when it's done I'll let you know how it turned out.

Thanxs.