Answered
Currency Formatting without new/import
Background:
If the total is (for example) 375.00 (or any other whole dollar amount) the form only displays 375 (not 375.00)
LIkewise if the total is (for example) 559.50, the form only displays 559.5
The math is still correct, but the display isn't, we need it to display the trailing zeros properly.
Since with a cfform format=flash, I cannot use the new / import / (or some other functions) within actionscript, the currency formatting scripts I've found are not usable.
I created the following code to "append" the .00 or .n0 onto the end of the amount and display it in the field:
HERE IS THE PROBLEM...
This works most of the time, but sometimes it is dropping off the trailing zero.
For example,
pmt_qty = 3
pmt_amount = 62.30
fieldone = 0
fieldtwo = 0
fieldthree = 0
it should display 186.90, but it is displaying 186.9 (trailing zero doesn't work)
BUT
pmt_qty = 2
pmt_amount = 62.30
fieldone = 0
fieldtwo = 0
fieldthree = 0
It should (and does) display 124.60 (trailing zero works)
I know this was rather long-winded, but I'm completely stumped and I'm sure its something small I've missed.
If anyone can lend some assistance, I'd greatly appreciate it!!
- Running cfmx7
- CFFORM FORMAT=FLASH
- I have several fields that are totaled using actionscript, most of these fields are user input, so virtually any dollar amount can be entered
If the total is (for example) 375.00 (or any other whole dollar amount) the form only displays 375 (not 375.00)
LIkewise if the total is (for example) 559.50, the form only displays 559.5
The math is still correct, but the display isn't, we need it to display the trailing zeros properly.
Since with a cfform format=flash, I cannot use the new / import / (or some other functions) within actionscript, the currency formatting scripts I've found are not usable.
I created the following code to "append" the .00 or .n0 onto the end of the amount and display it in the field:
quote:
<CFSAVECONTENT variable="subTotal">
var a = (Number(pmt_qty.text) * Number(pmt_amount.text))+Number(fieldone.text)+Number(fieldtwo.text)+Number(fieldthree.text);
if(!(Number(a)%1)){subtotal.text = Number(a)+".00"}
if(Number(a)%1){subtotal.text = Number(a)}
var b = (Number(a)*10);
if(!(Number(b)%1) && (Number(a)%1)){subtotal.text = Number(a)+"0"}
</CFSAVECONTENT>
HERE IS THE PROBLEM...
This works most of the time, but sometimes it is dropping off the trailing zero.
For example,
pmt_qty = 3
pmt_amount = 62.30
fieldone = 0
fieldtwo = 0
fieldthree = 0
it should display 186.90, but it is displaying 186.9 (trailing zero doesn't work)
BUT
pmt_qty = 2
pmt_amount = 62.30
fieldone = 0
fieldtwo = 0
fieldthree = 0
It should (and does) display 124.60 (trailing zero works)
I know this was rather long-winded, but I'm completely stumped and I'm sure its something small I've missed.
If anyone can lend some assistance, I'd greatly appreciate it!!