RE: dynamically setting 'selected' in option tag
> -----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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format