Making a "text2" override "text1" in Acrobat

New Here ,
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, Macintosh, Windows

Views

185

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
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;

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
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?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jun 07, 2018

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
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?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jun 07, 2018

Copy link to clipboard

Copied

Look under their Calculate tab, not Validate.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
amarism26678520 AUTHOR LATEST
New Here ,
Jun 07, 2018

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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