Conditional display of xform control

149 views
Skip to first unread message

kanchan

unread,
Dec 30, 2016, 1:44:42 AM12/30/16
to orb...@googlegroups.com
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>



And I have input boxes in TDs.


<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>



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.



--
View this message in context: http://discuss.orbeon.com/Conditional-display-of-xform-control-tp4662071.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

Alessandro Vernet

unread,
Dec 30, 2016, 2:37:58 AM12/30/16
to orb...@googlegroups.com
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
--
View this message in context: http://discuss.orbeon.com/Conditional-display-of-xform-control-tp4662071p4662073.html

kanchan

unread,
Dec 30, 2016, 2:58:55 AM12/30/16
to orb...@googlegroups.com
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.

--
View this message in context: http://discuss.orbeon.com/Conditional-display-of-xform-control-tp4662071p4662074.html

Alessandro Vernet

unread,
Dec 30, 2016, 11:09:34 AM12/30/16
to orb...@googlegroups.com
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
--
View this message in context: http://discuss.orbeon.com/Conditional-display-of-xform-control-tp4662071p4662076.html

kanchan

unread,
Dec 31, 2016, 8:42:15 AM12/31/16
to orb...@googlegroups.com
Hi Alex,

Thanks for replying and helping me. I will be more specific.
I have code this

Simple Price

<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>

Description
<xforms:textarea ref="Common-price/Price/Description" xxforms:rows="3"
xxforms:cols="60">
<xforms:label /></xforms:textarea>/td>


Price High

<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>
Description
<xforms:textarea ref="Common-price/Range-Price/Price-high/Description"
xxforms:rows="3" xxforms:cols="60"><xforms:label /></xforms:textarea>

Same for ref="Common-price/Range-Price/Price-low/Value" (low value and
description)

Now same details in other tr/td like Detailed price with ref like
ref="Specific-price/Price/Value", ref="Specific-price/Price/Description"
ref="Adult-price/Price/Value", ref="Adult-price/Price/Description"

This one file (pricedetails.xml)
<xforms:group model='Airport-model' ref="pricedetails'>
</xforms:group>
is included in other xml file (myfile.xml)

In myfile.xml we have complete form with HTML tr-td and various other fields
Name, Desc, email, etc.

<xforms:group>
<xi:include href="oxf:/apps/airport/Modules/PriceDetails.xml"
xxi:omit-xml-base="true" />
</xforms:group>


Same way in myfile.xml, one more file is included (other-details.xml)

<xforms:group>
<xi:include href="oxf:/apps/airport/Modules/other-details.xml"
xxi:omit-xml-base="true" />
</xforms:group>


In other-details.xml, again PriceDetails.xml is included
On click of '+', form in Otherdetails.xml (nodeset='otherdetails/service')
get displayed/repeated.

What I want is on the form,
if "Simple Price" is selected, tr for (Simple - price, desc) should get
displayed
If "Range" is selected, tr for Range and same for detailed one.

Here is the price template
<PriceDetails type="">
<Common-price>
<Price>
<Value /><Description />
</Price>
<Range-Price>
<Price-high><Value /><Description /></Price-high>
<Price-low><Value /><Description /></Price-low>
</Range-Price>
</Common-price>
<Specific-price>
<Price><Value /><Description /></Price>
<Price_special><Value /><Description /></Price_special>
</Specific-price>
</PriceDetails>

Used in two places
Details/information/pricedetails.......
Details/information/otherdetails/service/pricedetails....... (this nodeset
gets repeated on click of + icon)

How to achieve this?
if(price = 1) then
of simple price
if(price = 2) then
of range price
if(price = 3) then
of details price

And if above is achieved, then on submitting the data, will other nodes
(nodes of details and range if simple is selected) will get added in xml
file.

Please help me.



--
View this message in context: http://discuss.orbeon.com/Conditional-display-of-xform-control-tp4662071p4662084.html

kanchan

unread,
Dec 31, 2016, 8:46:21 AM12/31/16
to orb...@googlegroups.com
Hi Alex,

Thanks for replying and helping me. I will be more specific.
I have code this

Simple Price

<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>

Description
<xforms:textarea ref="Common-price/Price/Description" xxforms:rows="3"
xxforms:cols="60">
<xforms:label /></xforms:textarea>/td>


Price High

<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>
--
View this message in context: http://discuss.orbeon.com/Conditional-display-of-xform-control-tp4662071p4662085.html

kanchan

unread,
Dec 31, 2016, 9:02:53 AM12/31/16
to orb...@googlegroups.com
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.



--
View this message in context: http://discuss.orbeon.com/Conditional-display-of-xform-control-tp4662071p4662086.html

kanchan

unread,
Jan 3, 2017, 7:25:40 AM1/3/17
to orb...@googlegroups.com
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)

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

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)

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

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)

</xforms:group>
How can we hide TR/TDs also with this?

Please help.


--
View this message in context: http://discuss.orbeon.com/Conditional-display-of-xform-control-tp4662071p4662089.html

Alessandro Vernet

unread,
Jan 11, 2017, 12:39:48 PM1/11/17
to orb...@googlegroups.com
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
--
View this message in context: http://discuss.orbeon.com/Conditional-display-of-xform-control-tp4662071p4662114.html
Reply all
Reply to author
Forward
0 new messages