These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to hide or disable a button when PDF is opened?

DrJohnnyFever
Registered: Nov 24 2011
Posts: 3
Answered

Greetings all,
First time poster, sooooo glad I found this forum. Anyway, I'm creating a pdf form using LiveCycle 8.0 that needs to hide or disable a button, when the pdf is first opened, depending on whether there is text present in a field on the form already. This would be due to users opening it, entering data in the text field, and then saving it previously.
 
Here is the javascript that I have tried so far.
 
var k = form1.Table.subject.Paragraph.subject_name.rawValue;
if (k.length != 0){
form1.Button1.presence = "Hidden";
form1.Button1.access = "readOnly";
}
 
I've put the code into the docReady, form:ready and layout:ready events of my form, but when I open the form after saving some text in the text field, the button is still visible upon closing and re-opening the form.
 
The weird part is, if I set the 'Default' property of the text box to any non null value and test it in the Preview tab, it works!
 
It seems as though the Default property is set (and detected) by the events above before any user-entered (and previously saved) text is loaded into the text box fields on a form, so the events that I'm checking don't seem to be catching the user entered text at the point that they fire.
 
Basically, I'm asking how do I check for text in a textfield and then disable or hide a button on the form upon the pdf being opened?
 
What events should have my code in them?
 
Thanks in advance for all replies,
 
DJF

My Product Information:
LiveCycle Designer, Windows
SmiffySan
Registered: Nov 4 2011
Posts: 11
Hi, I do much the same thing, I need something to disappear either when the form is opened or when the field is used.

If it's on opening, I use on 'Initialize'

xfa.event="true"
xfa.form.form1.subform.brmselect.presence="invisible";

If it's on some sort of entry or change, I use on 'Change'

xfa.event="true"
xfa.form.form1.subform.brmselect.presence="invisible";

Works for me!

A poor overworked muppet

DrJohnnyFever
Registered: Nov 24 2011
Posts: 3
SmiffySan wrote:
Hi, I do much the same thing, I need something to disappear either when the form is opened or when the field is used.If it's on opening, I use on 'Initialize'

xfa.event="true"
xfa.form.form1.subform.brmselect.presence="invisible";

If it's on some sort of entry or change, I use on 'Change'

xfa.event="true"
xfa.form.form1.subform.brmselect.presence="invisible";

Works for me!
Thanks for the reply SmiffySan (and I'm a huge fan of Homer also ;)...

But I was wondering, what did you mean by 'xfa.event="true" '? What event are you checking for? Also, which 'initialize' event do you put your code into? Is it the the initialize for the form containing the text fields, the initialize event for the text field itself, or somewhere else?

Thanks again,

DJF
SmiffySan
Registered: Nov 4 2011
Posts: 11
Hi DJF,

let me have your email address and I'll send you a sample.

You'll need to do it like this (I think) 'your.nameatseaside.com

Cos you can't use the 'at' symbol.

Cheers

Smiffysan

A poor overworked muppet

DrJohnnyFever
Registered: Nov 24 2011
Posts: 3
Accepted Answer
SmiffySan,
I solved the problem. My script just wasn't running. I forgot to open the form in Acrobat Pro and do an 'Advanced->Enable Usage Rights in Adobe Reader'. As soon as I did that everything ran fine.Thanks for your help!

DJF
SmiffySan
Registered: Nov 4 2011
Posts: 11
Doh!

A poor overworked muppet