[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: Larry_Mason@xxxxxx
Date: Thu, 13 Apr 2000 11:34:27 -0500
option tag
Just off the top of my pointed head
<statelist>
<name>AK</name>
<name>AZ</name>
...
</statelist>

in pseudo-code and maybe a starting point
<xsl:for-each statelist>
  <OPTION>
    <xsl:attribute name="value"><xsl:value-of select="position
()"/></xsl:attribute>
    when position = state
    <xsl:attribute name="selected">true</xsl:attribute>
   </OPTION>
</xsl:for-each>

Larry





Aaron Pekrul <apekrul@xxxxxxxxxxx>@mulberrytech.com on 04/13/2000 10:58:42
AM

Please respond to xsl-list@xxxxxxxxxxxxxxxx

Sent by:  owner-xsl-list@xxxxxxxxxxxxxxxx


To:   XSL-List@xxxxxxxxxxxxxxxx
cc:
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.

XML:
<DATA>
<STATE>1</STATE>
</DATA>


XSL:
<SELECT name="state" size="1">
<xsl:choose>
<xsl:when test="DATA/STATE='1'">
 <OPTION value="1" selected="true">AK</OPTION>
</xsl:when>
<xsl:when test="DATA">
<OPTION value="1" >AK</OPTION>
</xsl:when>
</xsl:choose>


<xsl:choose>
<xsl:when test="DATA/STATE='2'">
<OPTION value="2" selected="true">AZ</OPTION>
</xsl:when>
<xsl:when test="DATA">
<OPTION value="2" >AZ</OPTION>
 </xsl:when>
</xsl:choose>
</SELECT>

HTML:
 <SELECT name="state" size="1">
  <OPTION value="1" selected>AK</OPTION>
  <OPTION value="2">AZ</OPTION>
</SELECT>


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




 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.