Highlighted

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

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

 

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;
}
TOPICS
PDF forms

Views

104

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

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

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

 

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;
}
TOPICS
PDF forms

Views

105

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
Sep 27, 2020 0
Adobe Community Professional ,
Sep 27, 2020

Copy link to clipboard

Copied

Use a script at validation of field "ZFW".

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
Reply
Loading...
Sep 27, 2020 0
Most Valuable Participant ,
Sep 27, 2020

Copy link to clipboard

Copied

Drop the quotes around the numbers.

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
Reply
Loading...
Sep 27, 2020 0
Explorer ,
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...).

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
Reply
Loading...
Sep 27, 2020 0
Most Valuable Participant ,
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;
}

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
Reply
Loading...
Sep 27, 2020 0
Explorer ,
Sep 27, 2020

Copy link to clipboard

Copied

Thanks try67 😉 

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
Reply
Loading...
Sep 27, 2020 0