[xsl] default value in combobox

Subject: [xsl] default value in combobox
From: "Weber, Hans-Jürgen" <H-J.Weber@xxxxxx>
Date: Wed, 20 Aug 2003 11:00:49 +0200
Hello,

I want to show a default value for a combobox and an input field
(see test.xsl and test.xml below).
There are two loops in the xsl file:
One for the rows to be displayed and one for the combobox.

The output should be:

Test
row 1: Combobox1: Type 1  Field 1: Description 1
row 2: Combobox2: Type 2  Field 2: Description 1

but it is:

Test
row 1: Combobox1: Type 2  Field 1: Description 1
row 2: Combobox2: Type 2  Field 2: Description 1

What can I do?
Thanx.

test.xsl:

<?xml version="1.0" encoding="iso-8859-1"?>  
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>  
<xsl:template match="root">
<html>  
<head>  
   <title>Test</title>
</head>  
<body>
<h1>Test</h1>
<form name="form">
   <xsl:for-each select="/root/data/main/Agreement/Pgas/Pga">
   <p>
	<select name="pgatypeid{PgaTypeid}" size="1">	
	   <xsl:for-each select="/root/data/main/pgatypes/Pgatype">
         <option value="{PgatypeId}">
         <xsl:if
test="PgatypeId=/root/data/main/Agreement/Pgas/Pga/PgaTypeid">
            <xsl:attribute name="selected">selected</xsl:attribute>
         </xsl:if>             
          <xsl:value-of select="PgatypeName"/></option>                  
      </xsl:for-each> 
   </select>    
   <input name="pgacomment{PgaTypeid}" maxlength="40" value="{PgaComment}"/>
   </p>
   </xsl:for-each>
</form>
</body>  
</html>      
</xsl:template>
</xsl:stylesheet>

test.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="test.xsl" type="text/xsl"?>
<root>
   <!--********** XML DATA **********-->
   <data>
      <main>
         <pgatypes>               <!-- rows to be displayed -->
            <Pgatype>
               <PgatypeId>1</PgatypeId>
               <PgatypeName>Type 1</PgatypeName>
            </Pgatype>
            <Pgatype>
               <PgatypeId>2</PgatypeId>
               <PgatypeName>Type 2</PgatypeName>
            </Pgatype>
       </pgatypes>
       
       <Agreement>                <!-- default values to be displayed -->

            <Pgas>
               <Pga>
                  <PgaTypeid>1</PgaTypeid>
                  <PgaComment>Description 1</PgaComment>
               </Pga>
               <Pga>
                  <PgaTypeid>2</PgaTypeid>
                  <PgaComment>Description 2</PgaComment>
               </Pga>
            </Pgas>
         </Agreement>
      </main>
   </data>
</root>   

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


Current Thread