xsl-list
[Top] [All Lists]

Re: selecting HTML Options

2005-01-17 22:09:53
Chris_Graham(_at_)aami(_dot_)com(_dot_)au 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:

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

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:attribute>
      <xsl:if test="$contact/credit-card/expires/month =
                    @index">
        <xsl:attribute name="selected">
          <xsl:text>selected</xsl:text>
        </xsl:attribute>
      </xsl:if>
      <xsl:value-of select="@index"/>
    </xsl:element>
  </xsl:for-each>
</select>

-- 


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>