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

Button Properties

krm240
Registered: Apr 17 2009
Posts: 95
Answered

How does one change a button text
I was trying the following but it does not always work.
this.caption.value.text.value = "Hide Inst.";

I am using LC ES2 and JS

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Did you check the console for any errors?
What event do you use to execute the script?

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

scderacjor
Registered: Mar 27 2009
Posts: 123
You can't double click the button? When I do so, the text is highlighted and I just type in new text.

That or with the Object editor tab (on the right), under "Field" there is a field that says "Caption:".
krm240
Registered: Apr 17 2009
Posts: 95
Sorry scderacjor - confusing you
I am talking about using Javascript to change the button text
The command is
this.caption.value.text.value = "Hide Inst.";

And radzmar
I think you have the problem, it is a problem with which event to use.
The code is working but not the way I want it to.

The objective is to:
click on the 'Show Instructions' button, which will make 'visible' instructions that are on a hidden page, change the text to 'Hide Instructions'.
Click again, Page will hide (revert back to hidden), and change button text to 'Show Instructions'

I have tried using all in 1 click event, does not work
Experimenting with other events and multiple events now.

If anyone has experience on this ....
Else, after testing - will post my results.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

I would put the script into an if-expression, to ensure the correct function.
This could look like:

if(xfa.form.Form1.Page2.presence == "hidden"){xfa.form.Formular1.Page2.presence = "visible";this.caption.value.text.value = "hide Page 2";}else{xfa.form.Form1.Page2.presence = "hidden";this.caption.value.text.value = "show Page 2";}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

krm240
Registered: Apr 17 2009
Posts: 95
The code that I am using is as follows (same as yours):
if(xfa.form.Main.TaxPage.presence == "hidden")
{
this.caption.value.text.value = "Hide Instructions";
xfa.form.Main.TaxPage.presence = "visible";
}
else
{
this.caption.value.text.value = "Show Instructions";
xfa.form.Main.TaxPage.presence = "hidden";
}
If the button is located on a main page, it works fine.
If the button is located on the master page (which is what I want),
It will properly show/hide the page, but it does not change the Text value

So the question is how do I get this to work on a master page?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The problem is, that you reference two different located targets with your script in one action.
This will not work as long one target is a master page and one a body page.

If you use the button a a master page, you better put the script for the caption into the layout:ready event.

if(xfa.form.Form1.Page2.presence == "hidden"){this.caption.value.text.value = "Show";}else{this.caption.value.text.value = "Hide";}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

krm240
Registered: Apr 17 2009
Posts: 95
Yes, this does it very nicely
Many thanks