How to make sure changes applied directly after selecting dropdown?

Community Beginner ,
Dec 23, 2019 Dec 23, 2019

Copy link to clipboard

Copied

Hi guys,

I am newbie for Java and I have a problem here. I wrote the custom code script in "Bank country" field - if the dropdown selection is "Canada" , another field will be unhide. otherwise, the field will be hide all the time.

 

However, the changes will not appear immediately after I change the dropdown. Only if I click on the dropdown one more time, the changes will appear.

 

How to make the hide and unhide of field works immediately after i change the value of dropdown?

is there any way?

 

link to doc: form 

 

Hope to hear from you soon. Thanks.

TOPICS
Acrobat SDK and JavaScript, Create PDFs, How to

Views

70

Likes

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
Adobe Community Professional ,
Dec 23, 2019 Dec 23, 2019

Copy link to clipboard

Copied

Hi,

 

in edit mode right-click the dropdown field, select Properties from the context menu, go to the Options tab and down below in that dialogue box tick the box that is labeled "Commit selected value immediately"; you may also want to uncheck "Sort items" and "Allow users to enter custom text"

Likes

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 ,
Dec 23, 2019 Dec 23, 2019

Copy link to clipboard

Copied

I did that, but the same problem persists...

Likes

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 ,
Dec 23, 2019 Dec 23, 2019

Copy link to clipboard

Copied

This is the script i put in custom validation tab.

 

is it because I wrote it wrongly?

 

var v1 =this.getField("Bank country").valueAsString;

if(v1!="Japan" && v1!="Canada")
{this.getField("Transit number").required = false;
this.getField("Transit number").display = display.hidden;
this.getField("Text2").required = false;
this.getField("Text2").display = display.hidden;
this.getField("Account type").required = false;
this.getField("Account type").display = display.hidden;
this.getField("Text1").required = false;
this.getField("Text1").display = display.hidden;}

else if(v1=="Canada")
{this.getField("Transit number").required = true;
this.getField("Transit number").display = display.visible;
this.getField("Text2").required = true;
this.getField("Text2").display = display.visible;
this.getField("Account type").required = false;
this.getField("Account type").display = display.hidden;
this.getField("Text1").required = false;
this.getField("Text1").display = display.hidden;}

else
{this.getField("Transit number").required=false;
this.getField("Transit number").display=display.hidden;
this.getField("Text2").required=false;
this.getField("Text2").display=display.hidden;
this.getField("Account type").required=true;
this.getField("Account type").display=display.visible;
this.getField("Text1").required=true;
this.getField("Text1").display=display.visible;}

Likes

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
Adobe Community Professional ,
Dec 23, 2019 Dec 23, 2019

Copy link to clipboard

Copied

You can also check if you need to move  the script to custom key stroke in the Format tab instead and then add at the beggining of the script something like:

 

if(!event.willCommit)

console.println(!event.value);

 

{this.getField("thename ofthefield").value;

}

 

Also, expand  the Preview Pane (to the right margin of the working space); you will see a section named "FIELDS".

 

You may have to Organize the order of the calculated fields.

Likes

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 ,
Dec 23, 2019 Dec 23, 2019

Copy link to clipboard

Copied

it works when i put it into keystroke script, Thank you very much!!!

Likes

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
Adobe Community Professional ,
Dec 23, 2019 Dec 23, 2019

Copy link to clipboard

Copied

you're welcome

Likes

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
Most Valuable Participant ,
Dec 24, 2019 Dec 24, 2019

Copy link to clipboard

Copied

LATEST

From memory, in a validation script, the field has not yet changed (and may not change). So you can’t use getField to see the value just selected. And a validation script should be used only for validation, not side effects. 

Likes

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