This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: dynamically setting 'selected' in option tag


Look into using <xsl:attribute> so for example using your stylesheet:

<SELECT name="state" size="1"> 
 <OPTION value="1">
 <xsl:if test="DATA/STATE='1'">
  <xsl:attribute name="selected">true</xsl:attribute>
 </xsl:if>
 AK
 </OPTION>
...
</SELECT>

Hope that helps,
Mike

-----Original Message-----
From: owner-xsl-list@mulberrytech.com
[mailto:owner-xsl-list@mulberrytech.com]On Behalf Of Aaron Pekrul
Sent: Thursday, April 13, 2000 8:59 AM
To: XSL-List@mulberrytech.com
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]