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

Field Index Matching for JavaScript

Gattaca714
Registered: Dec 16 2009
Posts: 25

I'm using a static form.
 
On initialize event on Both Server and Client.
 
The field initializing the event is called fldBallotGroupCount
 
Code:
 
if(this.rawValue == 1){
BallotOrder.fldBoPvbmCount[0].presence = "hidden";
}
else if(this.rawValue == 2){
BallotOrder.fldBoPvbmCount[0].presence = "visible";
}
 
What this script is suppose to do is hide the field fldBoPvbmCount[0] if fldBallotGroupCount equals 1 when the pdf is created. In this example the code does not work because I don't think I'm calling the index of this field correctly. I have 6 total fields with this name indexed 0:5. If I change the field name to something unique then the code works. Example:
 
if(this.rawValue == 1){
BallotOrder.fldBoPvbmCountUnique.presence = "hidden";
}
else if(this.rawValue == 2){
BallotOrder.fldBoPvbmCountUnique.presence = "visible";
}
 
What is the proper way to index the field, or is this not possible?
 
Thanks.

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,
you have several options to do this.
1. The resolveNode method with and a loop.

  1. for (var i=0; i<5; i++)
  2. {
  3. xfa.resolveNode("Form1.BallotOrder.fldBoPvbmCount["+i+"]").presence = "visible";
  4. }
2. A script in the layoutReady:event of all fields named "fldBoPvbmCount".
this.presence = fldBallotGroupCount.rawValue == 1? "hidden":"visible";

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Gattaca714
Registered: Dec 16 2009
Posts: 25
Using method #2 I ended up with this code on the fldBoPvbmCount with layoutReady:event

if(fldBallotGroupCount.rawValue == 1){
this.presence = "hidden";
}
else if(fldBallotGroupCount.rawValue == 2){
this.presence = "visible";
}
else if(fldBallotGroupCount.rawValue == 3){
this.presence = "visible";
}
else if(fldBallotGroupCount.rawValue == 4){
this.presence = "visible";
}
else if(fldBallotGroupCount.rawValue == 5){
this.presence = "visible";
}

It works in livecycle when I change the default value, however I can't seem to apply it in our application. Our application using Itext sends a number 1:5 to fldBoPvbmCount at the time of creation but the fields don't hide. It's almost as if the event is triggered by the default value not the number in the fldBoPvbmCount. Any leads would be appreciated.



PS. I couldn't figure out how to use method 1.