Jump to content
Welcome to the new FusionPro User Forum! ×

NEED HELP....inserting text


strido

Recommended Posts

I tried searching for "text rule" or something, but :eek: there's alot of returns, and not a lot of help...

 

The issue is, I have two fields, a phone and an email. The actual text in the paragraph is as follows:

 

......contact me at (555) 555-5555 or someschmuck@duh.com.

 

Well, naturally the client apparently forgets to put in the email in their data, so it returns this:

 

......contact me at (555) 555-5555 or .

 

That looks pretty silly. Currently the "or" is typeset into the textbox. I'd like to put it in a rule so that when this happens, the "or" will be omitted when I check "suppress when empty".

 

Now that I think about it I'll probably need a rule for CustomLine01 (the phone number) because next time that'll be the one they omit.

 

#@(*#(

Link to comment
Share on other sites

Give this a shot, put in your Field names:

 

if (Field("Email") == "")

return "contact me at " + (Field("Phone")+ ".");

else

return "contact me at " + (Field("Phone")+ " or " + (Field("Email")));

Link to comment
Share on other sites

You're right, you're going to want to account for all instances of "blanks" in the data so in addition to the email addresses you also want to have a rule for the phone numbers. Or you can put them all into one rule like this:

 

var result= "";

result += (Field("Phone") != "" || Field("Email") != "") ? "Feel free to contact me at " : "";
result += (Field("Phone") != "" ) ? Field("Phone") : "";
result += (Field("Phone") != "" && Field("Email") != "") ? " or " : "";
result += (Field("Email") != "" ) ? Field("Email") : "" ;

return result;

 

This way if both both fields are left blank, the entire sentence will not print. However, if just phone is populated it will return "Feel free to contact me at [phone]" and if just email is populated, it will return "Fee free to contact me at .

Link to comment
Share on other sites

This way if both both fields are left blank, the entire sentence will not print. However, if just phone is populated it will return "Feel free to contact me at [phone]" and if just email is populated, it will return "Fee free to contact me at .

More generalized:

function removeEmptyItems(inArray)
{
 var newArray = new Array();
 for (var i = 0; i < inArray.length; i++)
 {
     if (inArray[i])
       newArray.push(inArray[i]);
 }
 return newArray;
}

var arr = removeEmptyItems([Field("Phone"), Field("Email")]);

return arr.length ? "Feel free to contact me at " + arr.join(" or ") : "";

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...