kenstraker Posted September 1, 2013 Share Posted September 1, 2013 Hi All I am very new to fusion pro and i am in need of some advice. I am creating a business card lets say with two rows with two fields in each row ie <<phone>> <<Fax>> <<mobile>> <<e-mail>> So what i am trying to achieve is if any field is empty i want to suppress, and move to the next available field, move the field horizontally and Vertically if fax is empty move mobile in it's place and move e-mail left. Is this possible? Thanks in advance. Ken Straker Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted September 3, 2013 Share Posted September 3, 2013 I would do something like this: var items = [ Field("phone"), Field("Fax"), Field("mobile"), Field("e-mail") ]; items = items.filter(String); // remove empty items return [ items.slice(0, 2).join(" "), items.slice(2).join(" ") ].join("<br>\n"); Quote Link to comment Share on other sites More sharing options...
step Posted September 3, 2013 Share Posted September 3, 2013 Shouldn't you filter the second array to avoid a line break being added after a string with 2 or less items? return [ items.slice(0, 2).join(" "), items.slice(2).join(" ") ][color="Red"].filter(String)[/color].join("<br>\n"); Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted September 3, 2013 Share Posted September 3, 2013 Shouldn't you filter the second array to avoid a line break being added after a string with 2 or less items? Yes, if there's something else after these lines on the card that needs to move up. The original poster wasn't specific about that. Quote Link to comment Share on other sites More sharing options...
kenstraker Posted September 4, 2013 Author Share Posted September 4, 2013 Hi Guys Thanks for you swift response, i am not sure what i am doing wrong,but when i use the rule i get line 2: typeError: items.filter is not a function What am i missing? Regards ken Quote Link to comment Share on other sites More sharing options...
kenstraker Posted September 4, 2013 Author Share Posted September 4, 2013 Hi Guys One small thing i did'nt mention if iam using a FaxNumberRule ie Tel: +44 (0) to return before my phone or fax number how will this work in the rule? Regards Ken Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted September 4, 2013 Share Posted September 4, 2013 Thanks for you swift response, i am not sure what i am doing wrong,but when i use the rule i get line 2: typeError: items.filter is not a function What am i missing? That's because you're using a version of FusionPro older than 8.0. I would have known this if either (a) you specified the version you're using in your post, or in your signature or (b) my ESP was working. See my signature below for recommendations on how to be specific about the versions of things you're using in order to get better answers to your questions. In your older version of FusionPro, you can add the code from this post to your JavaScript Globals: http://forums.pti.com/showpost.php?p=9280&postcount=2 One small thing i did'nt mention if iam using a FaxNumberRule ie Tel: +44 (0) to return before my phone or fax number how will this work in the rule? Sure, you can call out other rules to populate the array instead of just using fields, like so in the first line: var items = [ Rule("phoneNumberRule"), Rule("FaxNumberRule"), Rule("mobileNumberRule"), Field("e-mail") ]; Of course, I'm guessing at your other rule names. Quote Link to comment Share on other sites More sharing options...
kenstraker Posted September 5, 2013 Author Share Posted September 5, 2013 Thanks Dan Worked a treat Cheers Lovely jubilee Ken Straker 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.