MarkJonesEMKT Posted January 27, 2016 Share Posted January 27, 2016 Hello All, I want to be able to change how a line or paragraph is being justified based on the value of a specific field. I'm pretty new to both FP and JavaScript so I'm still figuring out syntax for these things. Here is what I am trying to do. if(Field("Name") != "") return "Centered Text" + Field("Name"); return "Left Justified Text" + Field("Name"); I thought I may be able to use the "<span>" tags and I looked through the reference guide, but I didn't see anything on this specifically. I really appreciate any help offered. Quote Link to comment Share on other sites More sharing options...
David Miller Posted January 27, 2016 Share Posted January 27, 2016 (edited) Hello All, I want to be able to change how a line or paragraph is being justified based on the value of a specific field. I'm pretty new to both FP and JavaScript so I'm still figuring out syntax for these things. Here is what I am trying to do. if(Field("Name") != "") return "Centered Text" + Field("Name"); return "Left Justified Text" + Field("Name"); I thought I may be able to use the "<span>" tags and I looked through the reference guide, but I didn't see anything on this specifically. I really appreciate any help offered. Try something like this. Be sure to check Treat returned strings as tagged text. if(Field("Name") != "") return '<p br="false" quad="C">' + Field("Name"); return '<p br="false" quad="L">' + Field("Name"); Edited January 27, 2016 by David Miller Quote Link to comment Share on other sites More sharing options...
step Posted January 27, 2016 Share Posted January 27, 2016 If the "Name" field is empty, you want to return some left-justified text and the "Name" field? That seems odd. Either way, the tag you're looking for is the paragraph tag (page 42 of the TagsRefGuide.pdf documentation). The "quad" attribute will allow you to adjust the alignment with values of "L," "R,", "C," and "J" (left, right, centered, and justified respectively). Keep in mind that a paragraph tag by default starts a new paragraph (adding a line break) so if you want to avoid a line break, use the 'br' attribute and set it to false. So in your situation, you just want to determine if the alignment should be a "C" or an "L" based on the value of the "Name" field: var align = Field("Name") ? 'C' : 'L'; var str = Field("Name") ? 'Centered Text' + Field("Name") : 'Left Justified Text'; return '<p br=false quad=' + align + '>' + str; Quote Link to comment Share on other sites More sharing options...
MarkJonesEMKT Posted January 28, 2016 Author Share Posted January 28, 2016 When I try either of these options, I am getting the following result justified however the original paragraph settings had it. <p br="false" quad="C">Name Quote Link to comment Share on other sites More sharing options...
step Posted January 28, 2016 Share Posted January 28, 2016 Did you see this? Be sure to check Treat returned strings as tagged text. Quote Link to comment Share on other sites More sharing options...
MarkJonesEMKT Posted January 28, 2016 Author Share Posted January 28, 2016 Did you see this? I had seen this, that is one of the things I do by default when I create a rule because almost everything needs it. I think something was going on with the server, because when I restarted it began working. Thanks for the help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.