Expand my Community achievements bar.

Can I get a button to disappear when I click it?

Avatar

Former Community Member
Really kind of a newb when it comes to some of this stuff. Any help would be appreciated.
9 Replies

Avatar

Level 4
Yes you can. The visibility of form elements is controlled by the "presence" attribute.



xfa.form.form1.Pg1.myButton1.presence = "visible";

xfa.form.form1.Pg1.myButton1.presence = "invisible";



Thom Parker

WindJack Solutions


www.windjack.com

Avatar

Former Community Member
Cool, but what do you do with that or where do you put it?

Avatar

Level 4
Ahhh, you are not familiar with JavaScript. To do this you are going to have to learn just a bit.



In Designer

1. select the button you want to disappear.

2. On the Script Editor window select "Click" (If the editor is not visible Look under the "Window" menu)

3. Add this line of code to the "Click" event.



this.presence = "invisible";



"this" refers to the current form element. Which because the code is inside the button click event, refers to the button.



Thom Parker

WindJack Solutions


www.windjack.com

Avatar

Former Community Member
Thank you Thank you Thank you. I never even knew that editor was there! That answers about a billion and a half of the questions/problems I have been having with this and other things. Thank you very much! Next time you're in Omaha I'm getting you a pizza.

Avatar

Level 4
What do mean by "old Acrobat 7"? Do you mean an AcroForm PDF. i.e., a PDF using the standard old form fields that you add in Acrobat?



For this you use the old "display" Field Property.



this.getField("myField").display = display.hidden;



or



this.getField("myField").display = display.visible;



Thom Parker

WindJack Solutions


www.windjack.com

Avatar

Former Community Member
Yes, that's exactly what I meant Thom. Thanks for clearing that up. AND thanks for the tip! :) You've already done more than enough, but could you tell me where this would go?

Avatar

Level 4
There are lots of JavaScript locations in a PDF. Where you put it depends on how you want to use it. For example, if you wanted to make a field hidden/visible by clicking on a button you'd put this script in the Buttons "MouseUp" Action.



Thom

Avatar

Former Community Member
Thanks Thom. This will be very usefull to me. Have a nice Monday.