Conditional display of xform control

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Conditional display of xform control


And I have input boxes in TDs.

What I want is based on selected value, display respective textbox. So, if I select simple, display only simple. If I select Range, display only range.

Please help me.

kanchan
Hi Team,



Please help me. I am new to xforms. I have price types (Simple - value=1, Range - value=2)
I am having one select1 control in details.xml as follows
Pricing Type<xforms:select1 ref="@type" appearance="full">
<xforms:label></xforms:label>
<xforms:itemset nodeset="instance('Price-instance')/Price-Type">
<xforms:label ref="name" />
<xforms:value ref="value" />
</xforms:itemset>
</xforms:select1>
<xforms:input ref="Common-price/Price/Value" xxforms:size="10">
<xforms:label style="display:none;">Simple Pricing->Price</xforms:label>
<xforms:alert>Use numbers and a decimal point, no letters or signs</xforms:alert>
</xforms:input>
<xforms:input ref="Common-price/Range-Price/Price-high/Value" xxforms:size="10">
<xforms:label style="display:none;">Price Range->Price-high</xforms:label>
<xforms:alert>Use numbers and a decimal point, no letters or signs</xforms:alert>
</xforms:input>
<xforms:input ref="Common-price/Range-Price/Price-low/Value" xxforms:size="10">
<xforms:label style="display:none;">Price Range->Price-low</xforms:label>
<xforms:alert>Use numbers and a decimal point, no letters or signs</xforms:alert>
</xforms:input>
Reply | Threaded
Open this post in threaded view
|

Re: Conditional display of xform control

Alessandro  Vernet
Administrator
Hi,

Thank you for sharing some of the source. Could you also give use the content of instance('Price-instance')?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Conditional display of xform control

kanchan
Here is price_instance

    <PriceDetails>
    <Price-Type>
        <name>Simple Pricing</name>
        <value>1</value>
    </Price-Type>
        <Price-Type>
            <name>Price Range</name>
            <value>2</value>
        </Price-Type>
        <Price-Type>
            <name>Detailed Pricing </name>
            <value>3</value>
            </Price-Type>
    </PriceDetails>

Please help me.
Reply | Threaded
Open this post in threaded view
|

Re: Conditional display of xform control

Alessandro  Vernet
Administrator
Got it, so in instance('Price-instance')/Price-Type, you'll have either 1, 2, or 3.
If you want to only show the first input when value is 1, you'll add the following in your model:

<xf:bind
    ref="Common-price/Price/Value"
    relevant="instance('Price-instance')/Price-Type = '1'"/>

The value of `ref` is the same as the `ref` on the <xf:input>. And this would assume that Common-price/Price/Value is in the first instance, and that Common-price is a child of the root element. BTW, since you have multiple instances, you might want to be more explicit, e.g. instance('my-instance')/Common-price/Price/Value.

You'll let us know if this helps,

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Conditional display of xform control

kanchan
Hi Alex,

Thanks for replying and helping me. I will be more specific.
I have form with
s. and in TDs, I have price with value and textarea for description.
All these price details (<xforms:input>  and <xforms:textarea>) are in TR/TD
What I want

if simple price is selected = 1
then display TR of simple price
if range price is selected = 2
then display TR of range price(High and Low)
if detailed price is selected = 3
then display all TRs of detailed price(adult, special, etc)

This xforms:select1 and all price inputs are in one file (pricedetails.xml) which is included in detailinfo.xml.
In detailsinfo.xml
pricedetails.xml and
otherdetails.xml (In this file again pricedetails.xml file is included) files are included
When click on plus icon nodeset (nodeset='otherdetails/service') of other details get displayed/repeated.

Please help me.

Reply | Threaded
Open this post in threaded view
|

Re: Conditional display of xform control

</xforms:group>
<xforms:group ref="if (./@type = '2') then . else ()">
</xforms:group>
<xforms:group ref="if (./@type = 'value of selected option') then . else ()">
</xforms:group>
How can we hide TR/TDs also with this?

Please help.
kanchan
In reply to this post by Alessandro Vernet
Hi Alex,

I tried two options
1) Using relevant in bind, however I have my xform controls in HTML tr/td.

2) <xforms:group ref="if (./@type = 'value of selected option') then . else ()">

With both the options controls (input box and textarea) are not displayed but TR/TDs are displayed
<xforms:group ref="if (./@type = '1') then . else ()">
Simple Pricing>
xform control for price value (xforms:input)xform control for price desc (xforms:textarea)
Range Pricing>
Price High xform control for price value (xforms:input)xform control for price desc (xforms:textarea)
Price low xform control for price value (xforms:input)xform control for price desc (xforms:textarea)
Details Pricing>
Price Adult xform control for price value (xforms:input)xform control for price desc (xforms:textarea)
Price Student xform control for price value (xforms:input)xform control for price desc (xforms:textarea)
Reply | Threaded
Open this post in threaded view
|

Re: Conditional display of xform control

Alessandro  Vernet
Administrator
Somehow the code you included in your message is causing some display issue in this formum. Could you create a full but minimal example that we can run, attach it to your response, and describe the behavior you're seeing with that example, and the behavior you wish to have?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet