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

Button (with Icon) Hidden or Visible dependent on another field value

Engaged ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

Hi,

 

Is it possible to either hide or reveal a button with a graphical icon, dependent upon another field value?? I am trying to get the button ("Button1") to display based upon the field "ZFW" value, if "ZFW" is in the range >=18.0 and <=22.0...

 

I know how to solve the above with a text field, but not sure if  its possible to use the button object (with icon) and run the same Javascript (Mouse Up/Mouse Down/On Focus/On Blur) - i've tried what i have currently and seems not, which may be down to the lack of custom calculation script possibility with a button?.

 

if (this.getField("ZFW").value >= "18.0" && this.getField("ZFW").value <= "22.0" ) {
event.target.display = display.visible;
}
else{
event.target.display = display.hidden;
}

 

 

TOPICS
PDF forms

Views

563

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 , Sep 27, 2020 Sep 27, 2020

If you want that the button will be made visible/hidden when the value of the text field changes you need to place the code under the text field's validation or calculation event, as buttons do not trigger any events like that, and change it to the following:

 

if (event.value >= 18 && event.value <= 22 ) {
	this.getField("Button1").display = display.visible;
} else{
	this.getField("Button1").display = display.hidden;
}

Votes

Translate

Translate
Community Expert ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

Use a script at validation of field "ZFW".

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 ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

Drop the quotes around the numbers.

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
Engaged ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

Thanks for the replies Bernd/try67 - I should add that it's the button object I am attempting to either have either visible or hidden, based upon the value in the "ZFW" field....the script I supplied in original post is what I was hoping to use in the button object itself, but doesn't appear to be possible? (quotes dropped by the way...).

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 ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

If you want that the button will be made visible/hidden when the value of the text field changes you need to place the code under the text field's validation or calculation event, as buttons do not trigger any events like that, and change it to the following:

 

if (event.value >= 18 && event.value <= 22 ) {
	this.getField("Button1").display = display.visible;
} else{
	this.getField("Button1").display = display.hidden;
}

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
Engaged ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

LATEST

Thanks try67 😉 

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