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

Field visibility

Runolfr
Registered: Oct 1 2008
Posts: 119
Answered

I have a text field that I'm trying to make visible or invisible based on the value of a checkbox in LiveCycle Designer 8.2 The javascript seems to trigger, but it doesn't change the visibility of the checkbox. Here's the code...

EquiptReqForm.MainForm.AppReqs.CLMCentral::change - (JavaScript, client)

if (this.rawValue == 1)
{
ClmDetails.presence = "visible";
ClmDetails.mandatory = "error";
ClmDetails.mandatoryMessage = "Specify Health Plans, Medical Groups, and Master Calendar Partners if CLM Central is selected.";
}
else
{
ClmDetails.presence = "invisible";
ClmDetails.mandatory = "disabled";
}

CLMCentral is the checkbox; ClmDetails is the text field (which defaults to invisible). Both controls are in the same sub-form. I get the mandatoryMessage after checking and un-checking the box, but the text field never becomes visible.

Is there something obvious that I'm missing?

UPDATE: The problem seems to be specific to the visibility code; with those lines commented out, the code that makes the field mandatory seems to work.

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Did you save the form as Dynamic? Form visibility is related to the form layout and is therefore a dynamic feature.

I personally think that "invisible" should be useful on a static form since it doesn't change the layout, but that's not how they designed it:(

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Runolfr
Registered: Oct 1 2008
Posts: 119
I just changed the PDF Render Format in the Form Properties to Dynamic XML Form, but that didn't fix the problem. Is that what you were talking about?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Well yes, but just to make sure do a saveAs to "Dynamic XML Form" and watch this video about adding the dynamic features. It shows how to do exactly what you want.

https://admin.adobe.acrobat.com/_a200985228/p87746471/

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Runolfr
Registered: Oct 1 2008
Posts: 119
Ah! The "Save As" does indeed make a huge difference. Thank you.
MelissaM
Registered: Jan 14 2009
Posts: 26
That video is very informative and helpful.

I'm not sure if it's ok to piggyback onto this topic, but I've got a related question.

I've successfully set up my form so that if the user checks CheckBox1 then TextField1 becomes visible. What I'd like to do is set it up so that if the user checks CheckBox1 or CheckBox2 or CheckBox3 then TextField1 becomes visible.

I'm stumped as to how to accomplish that task.


ETA: I figured it out. I knew the logic, but was having a problem figuring out Java's syntaxing. A little trial and error and I have succeeded.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
you need to move the visibility test to somewhere, where all the parameters can be tested. A good place would be the calculation script in "TextField1".

Something like this:

this.presense = (CheckBox1.rawValue || CheckBox2.rawValue || CheckBox3.rawValue)?"visible":"invisible";

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script