سؤال

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