MeeshKB Posted August 3, 2012 Share Posted August 3, 2012 Hi all. I am an absolute beginner with JavaScript. I have been reading and exploring trying to find the answers I need but have run into a roadblock. I am looking to create a rule which will use firstLineIndent to indent the text in a frame if a target field has a value. I am working on a business card project where the text aligns as follows: P: 123-456-7890___C: 123-456-7890 F: 123-456-7890___E: abcdefg@hij.com (underscores being space between the fields, as I can't figure out how to illustrate that here) Simple enough. If not for the little wrinkle that some individuals have extensions added to their phone numbers. In those cases, the Cell and Email text needs to move to the right about a half inch to accommodate the extension, making it look more like this: P: 123-456-7890 ext 1111____C: 123-456-7890 F: 123-456-7890____________E: abcdefg@hij.com My thought is to create a rule, which could be applied to the Cell and Email frames, which invokes a firstLineIndent if the Ext field has a value. I've gotten this far... if (Field("Ext") > "0") { So yeah...no idea how of the syntax required to do what I want. Or am I way out to lunch on this altogether? Quote Link to comment Share on other sites More sharing options...
ThomasLewis Posted August 4, 2012 Share Posted August 4, 2012 Hopefully this will set you in the right direction. Basically it sets up the tabstops as a variable based on if the extension number is filled out or not. I hardcoded in the phone numbers just so you can see how this would work. var tabval = "0;12000,Left"; var extpfx = ""; if (Field("Ext").length > 0) { tabval = "0;16000,Left"; extpfx = " ext "; } return '<p br="false" tabstops=' + tabval + '>' + "P: 123-456-7890" + extpfx + Field("Ext") + '<t>' + "C: 123-456-7890" + '<br>' + "F: 123-456-7890" + '<t>' + "E: abcdefg@hij.com"; Quote Link to comment Share on other sites More sharing options...
MeeshKB Posted August 7, 2012 Author Share Posted August 7, 2012 Thank you so much, Thomas. I had kept each field in a separate frame, so tabs hadn't occured to me, but this makes perfect sense. Off to try it now. Thanks again! Quote Link to comment Share on other sites More sharing options...
MeeshKB Posted August 7, 2012 Author Share Posted August 7, 2012 Okay, so perhaps not perfectly clear... Inserting that rule (and applying the appropriate fields) returns the following in preview: <p br="false" tabstops=0;16000,Left>P: 123-456-7890 ext 3042<t>C: 123-456-7890<br>F: 123-456-7890<t>E:abcdefg@hij.com Note: It did pick up my actual phone, cell, fax and email fields. I just didn't want to display them here. So I'm wondering if I've missed a step. Why is it returning the literal code? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted August 7, 2012 Share Posted August 7, 2012 So I'm wondering if I've missed a step. Why is it returning the literal code? Check the "Treat returned strings as tagged text" box. Quote Link to comment Share on other sites More sharing options...
MeeshKB Posted August 7, 2012 Author Share Posted August 7, 2012 Ah. Of course. Where is the foreheadSmack smilie? Thank you, Dan. Quote Link to comment Share on other sites More sharing options...
ThomasLewis Posted August 7, 2012 Share Posted August 7, 2012 If you want to keep them in separate frames you would need to create a rule for each of the two numbers on the right. var indent = "0"; if (Field("Ext").length > 0) indent = "7200"; return '<p br="false" findent=' + indent + '>' + Field("field name"); This sets the indent only if there is a value for the phone extension. 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.