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

Making a "text2" override "text1" in Acrobat

New Here ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

Hi guys,

Thanks for any help, I'm AWFUL with javascript and i've been scratching my head on this.

I'm trying to figure out the right script for making text box tiers essentially.

"Text1" is the lowest tier, and the last wanted option.

"Text2" is the preferred information.

I want to make it so that "Text3" shows "Text2", but if it's not available, "Text1" fills it in.

I've minimal to no javascript experience, so help with this is greatly appreciated!! I understand how to implement it for the most part under "Actions".

Thank you!!!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

383

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 Expert ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

Use this code as your field's custom calculation script:

var v1 = this.getField("Text1").valueAsString;

var v2 = this.getField("Text2").valueAsString;

event.value = (v2=="") ? v1 : v2;

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
New Here ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

Hmm, it's not working for some reason?

I ran it as a javascript, mouse up on all three text boxes.

Text 3 stays empty?

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 Expert ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

No, as I wrote, this needs to be used as the custom calculation script (of Text3).

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
New Here ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

Realizing this now, but having another hiccup

Text3 didn't show Text1 or Text2 immediately. It only showed Text2 after I started to put content in Text3 then deleted it. Is there any way to have it show up automatically?

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 Expert ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

It should happen automatically, unless Text1 or Text2 have calculated values as well. If that's the case you need to fix the fields calculation order so that Text3 is calculated either both of those fields.

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
New Here ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

How would I remove those calculations? There shouldn't be any. As it stands both Text1 and Text2 are marked as "Field value is not validated" under validate.

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 Expert ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

Look under their Calculate tab, not Validate.

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
New Here ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

LATEST

Thank you!! This fixed everything Hope you have a wonderful day/night

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