Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Getting Started, Learning, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 12th, 2016, 06:39 AM
hkenney hkenney is offline
Junior Community Member
 
Join Date: Jun 2015
Posts: 17
Default Change color of "@" symbol

I'm having trouble writing a rule to change the color of the "@" symbol to black while keeping the rest of the email address red. When I validate the rule it returns my field correctly but it is not changing the color when I preview it. I have checked and I labeled the color exactly how it is spelt in my loaded colors and I have "treat returned strings as tagged text" selected. What am I missing? Thanks!

Code:
return Field("Email").replace(/@/g, '<color name="Black">@</color>');

Last edited by hkenney; February 12th, 2016 at 06:43 AM..
Reply With Quote
  #2  
Old February 12th, 2016, 06:55 AM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Re: Change color of "@" symbol

Quote:
Originally Posted by hkenney View Post
I'm having trouble writing a rule to change the color of the "@" symbol to black while keeping the rest of the email address red. When I validate the rule it returns my field correctly but it is not changing the color when I preview it. I have checked and I labeled the color exactly how it is spelt in my loaded colors and I have "treat returned strings as tagged text" selected. What am I missing? Thanks!

Code:
return Field("Email").replace(/@/g, '<color name="Black">@</color>');
Hmmm. Your rule works for me. Are you sure you are inserting the rule into your text frame and not the Field Email?

You could also try escaping the ampersand, but I don't think it is necessary. This works for me as well.

Code:
return Field("Email").replace(/\@/gi, '<color name="black">@</color>');
__________________
David Miller
FusionPro VDP Creator 10.0.26
Adobe Acrobat Pro 2019.008.20074
Suitcase Fusion 20.0.0 (7653)
macOS High Sierra 10.13.6

Last edited by David Miller; February 12th, 2016 at 07:13 AM..
Reply With Quote
  #3  
Old February 12th, 2016, 09:16 AM
hkenney hkenney is offline
Junior Community Member
 
Join Date: Jun 2015
Posts: 17
Default Re: Change color of "@" symbol

Thanks for looking into this David! Yes I am inserting the rule into the text field. I have been trying and trying and nothing is working. Could it be because the red color in the rest of the string is a spot color? I can't see why that would matter but I'm trying to think of anything!

Thanks,

Hilary
Reply With Quote
  #4  
Old February 12th, 2016, 09:39 AM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Re: Change color of "@" symbol

Quote:
Originally Posted by hkenney View Post
Could it be because the red color in the rest of the string is a spot color? I can't see why that would matter but I'm trying to think of anything!
It is working for me regardless of spot or process. Maybe you could collect and upload your template?
__________________
David Miller
FusionPro VDP Creator 10.0.26
Adobe Acrobat Pro 2019.008.20074
Suitcase Fusion 20.0.0 (7653)
macOS High Sierra 10.13.6
Reply With Quote
  #5  
Old February 12th, 2016, 09:43 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Change color of "@" symbol

Quote:
Originally Posted by David Miller View Post
Hmmm. Your rule works for me. Are you sure you are inserting the rule into your text frame and not the Field Email?
Hilary, I think what David is saying here is that maybe you're inserting your "Email" field into your text frame as opposed to the rule you used to manipulate your "Email" field. You can change your rule to something like this to make sure your template is pulling in the correct rule:
Code:
return "Yep, I'm the Email rule!";
I agree that your rule looks like it should work. We'd probably have to see your actual template to get a better idea of what's happening. That being said, another thing you could try is using span tags rather than color tags:
Code:
return Field("Email").replace('@','<span color="Black">@</span>');
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #6  
Old February 12th, 2016, 11:40 AM
hkenney hkenney is offline
Junior Community Member
 
Join Date: Jun 2015
Posts: 17
Default Re: Change color of "@" symbol

Yes, I am using the rule not the email field in the text box. I tried collecting and uploading and that didn't work. Also, I tried using span tags and it is still not working. I am attaching my collect files. Thanks so much guys!
Attached Files
File Type: zip Collect2.zip (2.73 MB, 12 views)
Reply With Quote
  #7  
Old February 12th, 2016, 12:48 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Change color of "@" symbol

Okay well now I understand. The rule in your template is not the same as the rule that you posted to the forum. The rule in your template is missing the "name" property for the "color" tag and it's looking for the HTML entity of the '@' symbol rather than the '@' symbol itself:
Code:
return Field("Email").replace(/& # 6 4 ;/g, '<color ="Black">& # 6 4 ;</color>');
Since your data isn't passing the "@" as the HTML entity, there's no reason to search for it in that field. So ironically, if I change your rule to match the code in your original post (after the forum converted the entity to the @ symbol), I get the desired result:
Code:
return Field("Email").replace(/@/g, '<color name="Black">@</color>');
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #8  
Old February 12th, 2016, 12:54 PM
hkenney hkenney is offline
Junior Community Member
 
Join Date: Jun 2015
Posts: 17
Default Re: Change color of "@" symbol

IT WORKED!! Sorry I've been trying so many variations I must have lost the name property somewhere along the way. Thank you so much!!
Reply With Quote
Reply

Tags
change, color, replace, symbol

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 06:59 PM.


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