Populating Dropdown List with Sequence Numbers

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

Populating Dropdown List with Sequence Numbers

Spenser Kao

Has anyone successfully populated dropdown list with sequence numbers?

Take example of credit card expiry date’s year, rather than requiring the user input it into an input box, it could be reasonable to populate a dropdown list with a sequence of numbers, for instance 2006 to 2020. I tried the code below, but resulting in an empty dropdown list even there was no run-time error.

 

Has anyone tried the similar thing successfully?

 

Regards,

 

Spenser

 

**** Start of Test Code ****

<xforms:select1 ref="instance('signup')/expiry-date-year" appearance="minimal">

<xforms:label>Expiry Date Year: </xforms:label>

    <xsl:for-each select="2006 to 2020">

        <xforms:item>

            <xforms:label>

                <xforms:output value="."/>    <!— neither xxforms:evaluate(.) nor number(.) made it work either à

            </xforms:label>

            <xforms:value>

                <xforms:output value="."/>

            </xforms:value>

        </xforms:item>

    </xsl:for-each>

</xforms:select1>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Populating Dropdown List with Sequence Numbers

Ryan Puddephatt
<xforms:output value="{.}"/> should do it, the value of the . will only be placed when AVTs are used, but I'm not sure you can do 2006 to 2020 as xsl:for-each should take a nodeset! You might need to use recursive templates
 
Hope this helps
 
Ryan
 

Ryan Puddephatt
Software Engineer
 

Teleflex Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotland
EH54 7DP
 
e> [hidden email]
t> +44(0)1506 407 110
f> +44(0)1506 407 108
w> www.teleflex.com

 


From: Spenser Kao [mailto:[hidden email]]
Sent: 20 October 2006 12:12
To: [hidden email]
Subject: [ops-users] Populating Dropdown List with Sequence Numbers

Has anyone successfully populated dropdown list with sequence numbers?

Take example of credit card expiry date’s year, rather than requiring the user input it into an input box, it could be reasonable to populate a dropdown list with a sequence of numbers, for instance 2006 to 2020. I tried the code below, but resulting in an empty dropdown list even there was no run-time error.

 

Has anyone tried the similar thing successfully?

 

Regards,

 

Spenser

 

**** Start of Test Code ****

<xforms:select1 ref="instance('signup')/expiry-date-year" appearance="minimal">

<xforms:label>Expiry Date Year: </xforms:label>

    <xsl:for-each select="2006 to 2020">

        <xforms:item>

            <xforms:label>

                <xforms:output value="."/>    <!— neither xxforms:evaluate(.) nor number(.) made it work either à

            </xforms:label>

            <xforms:value>

                <xforms:output value="."/>

            </xforms:value>

        </xforms:item>

    </xsl:for-each>

</xforms:select1>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Populating Dropdown List with Sequence Numbers

Erik Bruchez
Administrator
In reply to this post by Spenser Kao
Spenser,

In your code below your are mixing XSLT and XForms. The main thing to
understand is that this is a two-step process:

1. XSLT runs only once for the page, and *produces* an XForms page

2. The resulting XForms page is processed by the XForms engine

So if you "unroll" your XSTL, you obtain the following markup, before
XForms processing:

   <xforms:item>
       <xforms:label>
           <xforms:output value="."/>
       </xforms:label>
       <xforms:value>
           <xforms:output value="."/>
       </xforms:value>
   </xforms:item>
   <xforms:item>
       <xforms:label>
           <xforms:output value="."/>
       </xforms:label>
       <xforms:value>
           <xforms:output value="."/>
       </xforms:value>
   </xforms:item>
   ...

Now just ask yourself whether the above XForms code does what you want
it to do ;-) The answer is obvsiously no, because "." refers to the
current XForms context, defined by the @ref attribute on
xforms:select1:

   ref="instance('signup')/expiry-date-year"

I you still want to go the XSLT way, then try instead something like:

   <xsl:for-each select="2006 to 2020">
       <xforms:item>
           <xforms:label>
               <xsl:value-of select="."/>
           </xforms:label>
           <xforms:value>
               <xsl:value-of select="."/>
           </xforms:value>
       </xforms:item>
   </xsl:for-each>

Optionally, you could get rid of XSLT and use an itemset in XForms,
pointing to an XForms instance dynamically populated upon
xforms-ready.

-Erik

 > Has anyone successfully populated dropdown list with sequence
 > numbers?
 >
 > Take example of credit card expiry date$(Bs (Byear, rather than
 > requiring the user input it into an input box, it could be
 > reasonable to populate a dropdown list with a sequence of numbers,
 > for instance 2006 to 2020. I tried the code below, but resulting in
 > an empty dropdown list even there was no run-time error.
 >
 > Has anyone tried the similar thing successfully?
 >
 >
 >
 > Regards,
 >
 >
 >
 > Spenser
 >
 >
 >
 > **** Start of Test Code ****
 >
 > <xforms:select1 ref="instance('signup')/expiry-date-year"
 > appearance="minimal">
 >
 > <xforms:label>Expiry Date Year: </xforms:label>
 >
 >     <xsl:for-each select="2006 to 2020">
 >
 >         <xforms:item>
 >
 >             <xforms:label>
 >
 >                 <xforms:output value="."/>    <!$(O n(Beither
 > xxforms:evaluate(.) nor number(.) made it work either à
 >
 >             </xforms:label>
 >
 >             <xforms:value>
 >
 >                 <xforms:output value="."/>
 >
 >             </xforms:value>
 >
 >         </xforms:item>
 >
 >     </xsl:for-each>
 >
 > </xforms:select1>

--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Populating Dropdown List with Sequence Numbers

Erik Bruchez
Administrator
In reply to this post by Ryan Puddephatt
Ryan,

 > <xforms:output value="{.}"/> should do it, the value of the . will
 > only be placed when AVTs are used

This may or may not work, but as I pointed out you can get rid of
xforms:output and just use the literal value, computed with XSLT,
within xforms:label and xforms:value.

 > but I'm not sure you can do 2006 to 2020 as xsl:for-each should take
 > a nodeset! You might need to use recursive templates

No need for that with XSLT 2.0! xsl:for-each takes a sequence, which
can indeed be a sequence of numeric values.

-Erik

--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws