RE: Hide/show select options

Hello
OK. How about adding:

<xf:rebuild ev:event="xforms-value-changed"/>

in the <xf:input> so that when you change the value there, it rebuilds the
rest of the form for you. You might need to give your model an ID,
especially if there is more than one.

This does work (at least with formsPlayer), but you need something like
the nodeset I suggested. The relevant bind still doesn't seem to work with
formsPlayer.

You can put the nodeset for the itemset into a bind if you like using
binds or want to keep XPath out of the UI.

Swithun.

On Mon, 6 Jun 2005, Jonathan Curtis wrote:

> Thanks for reply.
>
> This doesn't work. It produces the correct option list at the start, but the list doesn't change when the value of the instance('inst') node changes.
>
> -----Original Message-----
> From: Swithun Crowe [mailto:swithun@swithun.servebeer.com]
> Sent: 06 June 2005 13:50
> To: Jonathan Curtis
> Cc: www-forms@w3.org
> Subject: Re: Hide/show select options
>
>
> Hello
> Something you could try is replacing:
>
> <xf:itemset nodeset="instance('form_data')/select/item">
>
> with something like:
>
> <xf:itemset nodeset="instance('form_data')/select/item[position() != 3
> or instance('inst') = 1]">
>
> (include any item which is either not the third one, or if 'inst' is 1,
> which is what your relevant bind says)
>
> So you have the logic deciding which items to include in the itemset in
> the nodeset attribute, rather than relying on a bind.
>
> Don't know how elegant you would call this, but it should work.
>
> SWithun.
>
>
> On Mon, 6 Jun 2005, Jonathan Curtis wrote:
>
> > Hi all,
> >
> > I have a situation where I need to hide or show an option in a select1 based on a value of another node. Whats the best approach to doing this?
> >
> > At the moment I am using this:
> >
> > <html xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events">
> >     <head>
> >         <title>Test XForm</title>
> >         <xf:model>
> >             <xf:instance id="inst">
> >                 <test>1</test>
> >             </xf:instance>
> >             <xf:instance id="form_data">
> >                 <form_data>
> >                     <select>
> >                         <value>1</value>
> >                         <item>
> >                             <label>one</label>
> >                             <value>1</value>
> >                         </item>
> >                         <item>
> >                             <label>two</label>
> >                             <value>2</value>
> >                         </item>
> >                         <item>
> >                             <label>three</label>
> >                             <value>3</value>
> >                         </item>
> >                     </select>
> >                 </form_data>
> >             </xf:instance>
> >             <xf:bind id="test" nodeset="/test"/>
> >             <xf:bind id="select" nodeset="instance('form_data')/select/value"/>
> >             <xf:bind nodeset="instance('form_data')/select/item[3]" relevant="instance('inst') = 1"/>
> >         </xf:model>
> >     </head>
> >     <body>
> >         <xf:input bind="test">
> >             <xf:label>test</xf:label>
> >         </xf:input>
> >         <xf:select1 bind="select">
> >             <xf:label>Select</xf:label>
> >             <xf:itemset nodeset="instance('form_data')/select/item">
> >                 <xf:label ref="label"/>
> >                 <xf:value ref="value"/>
> >             </xf:itemset>
> >         </xf:select1>
> >     </body>
> > </html>
> >
> > With the Novell XForms plugin the option is greyed out when not applicable, but you can still select the option. Formsplayer doesn't recognise the item is not relevant.
> >
> > I'm looking for the most elegant way to achieve this.
> >
> > Thanks,
> >
> > Jon
> >
> > ________________________________________________________________________
> > This e-mail has been scanned for all viruses by Star. The
> > service is powered by MessageLabs. For more information on a proactive
> > anti-virus service working around the clock, around the globe, visit:
> > http://www.star.net.uk
> > ________________________________________________________________________
>
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________
>
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________
>

Received on Monday, 6 June 2005 15:21:20 UTC