• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Blank Field in Span Property

Community Beginner ,
Oct 10, 2018 Oct 10, 2018

Copy link to clipboard

Copied

I’m working in Acrobat DC

I’m creating a business card template. The fields are EmpName, Title, PhysicalAdd, Telephone, FAX, and EmailAdd.

My dilemma is with EmailAdd. The employee can choose to have their email address on the card or not. Below in span 5 you will see that I have added the
@HSa.co.merced.ca.us to the span. All the worker does is enter the first part of their email in the EmailAdd field. If the employee leaves the EmailAdd field
blank/empty, @HSa.co.merced.ca.us will still print on the card. How can I accommodate for an blank/empty EmailAdd field?

var spans = event.richValue;

spans[0] = new Object();

spans[0].text =
this.getField("EmpName").valueAsString + "\r";

spans[0].fontWeight = 700;

spans[0].textSize = 9;

spans[1] = new Object();

spans[1].text = this.getField("Title").valueAsString + "\r \r";

spans[1].fontWeight = 700;

spans[1].fontStyle ="italic";

spans[2]= new Object();

spans[2].text = this.getField("PhysicalAdd").valueAsString + "\r \r";

spans[3] = new Object();

spans[3].text = this.getField("Telephone").valueAsString + ", Ext. " + this.getField("Extension").valueAsString + "\r";

spans[4] = new Object();

spans[4].text = this.getField("FAX").valueAsString + "\r";

spans[5] = new Object();

spans[5].text = this.getField("EmailAdd").valueAsString + "@hsa.co.merced.ca.us";

event.richValue = spans;

Thank you

TOPICS
Acrobat SDK and JavaScript , Windows

Views

328

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 11, 2018 Oct 11, 2018

You can use this:

spans[5].text = this.getField("EmailAdd").valueAsString;

if (spans[5].text != "") spans[5].text += "@hsa.co.merced.ca.us";

Votes

Translate

Translate
Community Expert ,
Oct 11, 2018 Oct 11, 2018

Copy link to clipboard

Copied

You can use this:

spans[5].text = this.getField("EmailAdd").valueAsString;

if (spans[5].text != "") spans[5].text += "@hsa.co.merced.ca.us";

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 11, 2018 Oct 11, 2018

Copy link to clipboard

Copied

LATEST

Thank you so much Bernd. I was trying to use an if statement but wasn't using the spans with it. Makes sense now.

Thanks again, it works perfectly!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines