(XForms/betterFORM) Use values of elements to set values of other elements

36 Views Asked by At

I'm new to XForms and I have a question about using values of elements in setting values of other elements. The following code snippet shows what I want to do. The value of the element "item" should set as the current date + 5 more days. Works fine! But what if the number of the days are variable and depends on values of another element. For example there is another element in the path items/ called "item2". Is it possible to add the value of item2 (which is a number) to the current date? Thanks for answers!

<xf:action>
    <xf:setvalue ref="//items/item" value="current-dateTime() + xs:dayTimeDuration('P5D')"/>
</xf:action>

Best regards, Felix

1

There are 1 best solutions below

0
ebruchez On

You need to create a valid xs:dayTimeDuration value. For example this should work:

<xf:setvalue
    ref="//items/item"
    value="
        current-dateTime() +
            xs:dayTimeDuration(
                concat(
                    'P',
                    ../item2,
                    'D'
                )
            )"/>