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

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

Views

291

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 ,
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"

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

Copy link to clipboard

Copied

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

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 ,
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;}

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 ,
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.

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

you're welcome

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
LEGEND ,
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. 

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