[英]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.我需要一些建议如何通过 position 来 select 一个元素,无论它在文档中的哪个位置。 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?是否可以检查文档中第五个元素“a”的值(从头开始),无论它在哪个子表单中? Something like
if (xfa.resolveNode(Document.Subform[*].a[5]).rawValue === "y") {do something}
类似
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 ).警告这是 Javascript 方式而不是生命周期解决方案(小心)。
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.您的问题很有趣,因为我想您想包装所有这些子表单并立即检查名为“a”的输入中的值是否为“y”,我不确定是否存在。
My solution for that will be to iterate over document.forms because we don't now their name.我的解决方案是遍历 document.forms 因为我们现在不知道他们的名字。
The next will be create a map definition in which form appears that expected value.接下来将创建一个 map 定义,其中的形式出现该预期值。
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.可能以其他方式存在并进行了优化以将其全部包装并对其进行迭代。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.