[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] selecting HTML Options

Subject: Re: [xsl] selecting HTML Options
From: Daniel Bibbens <dbibbens@xxxxxxxxxx>
Date: Mon, 17 Jan 2005 21:09:53 -0800

Chris_Graham@xxxxxxxxxxx writes:

> There has to be an easier way to select <option> elements inside a 
> <select> element that this:
> [...snip...]
> Can anyone point me in the right direction? I'd rather avoid calling java 
> directly... :-(
> -Chris

I don't know if you'd view this as easier, but it might give you an
idea. Note that months.xml has the following form:

  <month index="1" abbrev="Jan">January</month>
  <month index="2" abbrev="Feb">February</month>
  <month index="3" abbrev="Mar">March</month>
  <month index="4" abbrev="Apr">April</month>
  <month index="5" abbrev="May">May</month>
  <month index="6" abbrev="Jun">June</month>
  <month index="7" abbrev="Jul">July</month>
  <month index="8" abbrev="Aug">August</month>
  <month index="9" abbrev="Sep">September</month>
  <month index="10" abbrev="Oct">October</month>
  <month index="11" abbrev="Nov">November</month>
  <month index="12" abbrev="Dec">December</month>

And this is the XSL:

<xsl:variable name="months" select="document('months.xml')/months"/>

<select NAME="cc.expires.month" title="select month">
  <xsl:for-each select="$months/month">
    <xsl:element name="option">
      <xsl:attribute name="value">
         <xsl:value-of select="@index"/>
      <xsl:if test="$contact/credit-card/expires/month =
        <xsl:attribute name="selected">
      <xsl:value-of select="@index"/>


Current Thread