Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Most efficient way to loop though many similarlly named fields?

$
0
0

 

Hi,

 

I have a 5 page document with each page containing appx. 50 similarly named fields.    E.g. Viol1Num, Viol2Num, Vio3Num ...  Viol50Num.

 

I am looking for an efficient way of programming a loop to look at each field in Javascript so I can do some manipulations in those fields on what the user entered.

 

In FormCalc I've previously used the 'foreach' function similar to:

 

foreach (Field1, Field2, Field3.....Field50) do

     'BLAH'

endfor

 

however, that gets really lengthy, especially when dealing with subsequent pages where I have to start adding 'topmostSubform.Page2.' in front of each field name so that I can access from the first page all of the fields on subsequent pages.  Also, I need to do this in Javascript, not FormCalc.

 

For example, in JS I am using this loop to mark all fields as read only:

   
for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++) {  

 var oFields = xfa.layout.pageContent(nPageCount, "field");


  

 var nNodesLength = oFields.length;


  

 for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {  


 oFields.item(nNodeCount).access = "readOnly";


  

 }


  
 }

 

How could I do something similar to that so I could look through each field and perform actions on it without having to list out every single field name?

 

 

 

I tried altering that to look at fields instead of field properties, but I couldn't get it to run.

 

Thanks.


Viewing all articles
Browse latest Browse all 12130

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>