문제

I just need help in xforms events. I've got boolean field - if the checkbox for the field is checked another field appears i.e Payment1 (I use relevant for this) to put amount in it - then I've got sum field. Problem is when I unchecked the field value of Payment1 is still count to Sum field. I would be grateful for event that clear value of the field Payment1 when the checkbox is unchecked.

도움이 되었습니까?

해결책

One option is to have an action that will set the value for Payment1 to an empty string.

In the example model below, if the element bar does not equal "checked" (the value of the select), then the element foo is set to an empty string.

    <xf:model>
        <xf:instance id="main">
            <data>
                <foo></foo>
                <bar></bar>
            </data>
        </xf:instance>
        <xf:bind nodeset="instance('main')/foo" relevant="following-sibling::bar='checked'"/>
        <xf:action ev:event="xforms-refresh">
            <xf:action if="instance('main')/bar[not(.='checked')]">
                <xf:setvalue ref="instance('main')/foo" value="''"/>                       
            </xf:action>
        </xf:action>
    </xf:model>

Here's an example of the select (bar) and the input (foo):

<table>
    <row>
        <td></td>
        <td>
            <xf:select ref="bar" selection="closed" appearance="full" incremental="true">
                <xf:item>
                  <xf:label>Click Me</xf:label>
                  <xf:value>checked</xf:value>
                </xf:item>
            </xf:select>
        </td>
    </row>
</table>
<table>
    <tr>
        <td>Input Foo: </td>
        <td>
            <xf:input incremental="true" ref="foo"/>
        </td>
    </tr>
</table>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top