Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library


Thread Tools Search this Thread Display Modes
Old February 14th, 2013, 10:07 AM
KatJones KatJones is offline
Junior Community Member
Join Date: Sep 2011
Location: Atlanta, GA
Posts: 22
Default Adding commas and dollar signs

I am sure this has been asked and discussed in maybe a different way. But I have search the forums and can't find a simple solution.

I have 5 data fields with dollar amounts in them. None have commas, or dollar signs.

In a perfect world I would just use the Number to Currency wizard for all 5 fields that FusionPro gives however....

Not all the data in those fields are numbers, some is text and they change whereas sometimes the "Other $_______ may be in field named AMT1 position.

Amt1= 25
Amt2= 50
Amt5=Other $________

Amt1= Other $________
Amt2=(Blank--will be suppressed)
Amt3=(Blank--will be suppressed)
Amt4=(Blank--will be suppressed)
Amt5=(Blank--will be suppressed)

Amt1= 25
Amt2= 50
Amt3=Other $________
Amt4=(Blank--will be suppressed)
Amt5=(Blank--will be suppressed)

I need to make it where the rule searches the field for numbers only and convert to currency formatting. And if it has text do not format.
FP 9.1.0 Producer, Windows Server 2008 R2, Acrobat 10.1.9
Reply With Quote
Old February 14th, 2013, 12:02 PM
step's Avatar
step step is offline
Senior Contributor
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Adding commas and dollar signs

Assuming you're trying to list these in one text field, this might work for you:

var amt = [];

for (var i=1; i<=5; i++){
    (Field("Amt" + i) != "") ? amt.push(Field("Amt" + i)) : "";
return amt.join("<br>").replace(/(\d+)/g,function(n){return FormatNumber("$###,###,###.00",n);});
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

Reply With Quote

formatting, javascript, text formatting

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 05:32 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.