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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 16th, 2019, 11:45 AM
-Lisa- -Lisa- is offline
Senior Contributor
 
Join Date: Sep 2008
Location: Long Island, NY
Posts: 190
Default Replace Symbol

Hello all,


Trying to come up with a way to remove a percentage symbol if it already exists in the data but return the symbol if it does not exist.


I already successfully created a replace rule for the presence of a dollar sign:

Code:
return Field("Price").replace('$', "");

If I simply replace the dollar symbol with a percentage symbol, I'm not getting the same result:
Code:
return Field("Percent").replace("", '%');

Any ideas on what I'm obviously doing wrong?



Thanks!
__________________
Lisa B.
FusionPro VDP Creator 10.0.16
Adobe Acrobat Pro DC 2018
Mac OS X 10.13.6 (High Sierra)
Reply With Quote
  #2  
Old May 16th, 2019, 02:10 PM
Leosmith Leosmith is offline
Junior Community Member
 
Join Date: Jun 2015
Location: Saint Paul
Posts: 41
Default Re: Replace Symbol

Code:
return Field("Percent").replace("", ' & # 3 7 ; ');
remove the spaces in ascii %

check - treat return string as tagged text
__________________
Leo Smith - Novice
FusionPro VDP Creator 10
Adobe Pro CC
Windows 7
Reply With Quote
  #3  
Old May 16th, 2019, 02:47 PM
-Lisa- -Lisa- is offline
Senior Contributor
 
Join Date: Sep 2008
Location: Long Island, NY
Posts: 190
Default Re: Replace Symbol

Thanks! Unfortunately this doesn't work. Just as with my version, it's returning the percentage sign in front of the number. It need the symbol after the number.
__________________
Lisa B.
FusionPro VDP Creator 10.0.16
Adobe Acrobat Pro DC 2018
Mac OS X 10.13.6 (High Sierra)
Reply With Quote
  #4  
Old May 17th, 2019, 08:17 AM
ScottHillock ScottHillock is offline
Regular Contributor
 
Join Date: Mar 2010
Posts: 91
Default Re: Replace Symbol

I believe you have the order of your parameters switched on your percentage example.

With replace the first parameter is what you are searching for, and the second is what to replace it with.

Here's a bit of code that covers both $ and %:

Code:
var fieldName = Field("field");

var field = fieldName.replace(/\$/g,'').replace(/\%/g,'');

if(fieldName.indexOf('$') > -1){return '$' + field;}
if(fieldName.indexOf('%') > -1){return field + '%';}

return field;
__________________
FusionPro 9.3.36 - Acrobat 11 - macOS 10.14
Reply With Quote
Reply

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 09:23 PM.


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