[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: dynamically setting 'selected' in option tag

Subject: RE: dynamically setting 'selected' in option tag
From: Kevin Williams <Kevin.Williams@xxxxxxxxxxxxxx>
Date: Thu, 13 Apr 2000 13:59:38 -0400
selected xslt option
> -----Original Message-----
> From: Aaron Pekrul [mailto:apekrul@xxxxxxxxxxx]
> Sent: Thursday, April 13, 2000 11:59 AM
> To: XSL-List@xxxxxxxxxxxxxxxx
> Subject: dynamically setting 'selected' in option tag
> 
> Does anyone know what the easiest way to trigger 'selected='true''
> dynamically.  The XML has a code from one to fifty to 
> represent one of the
> US states and I simply want to set 'select='true'' for this 
> value.  There
> must be an easier way than the code I have below for just two states.
> thanks.

Aaron,

You could use xsl:element and xsl:attribute to "build" the OPTION element,
rather than expressing it directly as a string. In other words, you could do
something like this:

<xsl:element name="OPTION">
  <xsl:attribute name="value">1</xsl:attribute>
  <xsl:if test="DATA/STATE='1'">
    <xsl:attribute name="selected">true</xsl:attribute>
  </xsl:if>
  <xsl:text>AK</xsl:text>
</xsl:element>

(repeat for next 49 states)

Still not great, but maybe a little better than what you've got at the
moment. Plus, if you're using XSLT, you could add another document that maps
numbers to state abbreviations, and then you could do something fancy using
xsl:document that wouldn't require a brute-force element block repeated 50
times...

- Kevin

Kevin Williams
XML Architect
Ultraprise Corporation
kwilliams@xxxxxxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.