简体   繁体   中英

Livecycle Designer: JavaScript - find an element by name and position from the root

I need some advice how to select an element by position no matter where it is in the document. For example let's say we have something like this:

Document    
 Subform
   a
   b
   a
 Subform
   b
   a
   c
 Subform
   a
   b
   a
   a
....

Is it possible to check the value for example of the fifth element "a" in the document (from the beginning) no matter in which Subform it is? Something like if (xfa.resolveNode(Document.Subform[*].a[5]).rawValue === "y") {do something}

Thank you in advance!

Warning this is a Javascript WAY not a livecycle solution ( take care ).

Your question is quite interesting, because i suppose you want to wrap all of that subforms and check at once the value is "y" inside the input named "a" im not sure if that exists.

My solution for that will be to iterate over document.forms because we don't now their name.

The next will be create a map definition in which form appears that expected value.

let hasExpectedValue = [].slice.call(document.forms).map((form)=>{
    return form.a.value === "y";
})

Then we can iterate and use the index which was true and do some stuff.

May exists other way and optimised to wrap it all and iterate over them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM