3.4.1.9 List Box Control

The following XSL examples are for list box controls, as specified in section 3.4.1.9.

The following example is a list box control with three selection entries.

 <select class="xdListBox xdBehavior_Select" title="" size="3" xd:binding="my:field1" xd:boundProp="value" tabIndex="0" xd:xctname="ListBox" xd:CtrlId="CTRL1" style="WIDTH: 130px">
     <xsl:attribute name="value">
         <xsl:value-of select="my:field1"/>
     </xsl:attribute>
     <option value="a">
         <xsl:if test="my:field1=&quot;a&quot;">
             <xsl:attribute name="selected">selected</xsl:attribute>
         </xsl:if>A</option>
     <option value="b">
         <xsl:if test="my:field1=&quot;b&quot;">
             <xsl:attribute name="selected">selected</xsl:attribute>
         </xsl:if>B</option>
     <option value="c">
         <xsl:if test="my:field1=&quot;c&quot;">
             <xsl:attribute name="selected">selected</xsl:attribute>
         </xsl:if>C</option>
 </select>

The following example is a list box control that looks up the selection options from a repeating group within the main data source. The control only displays unique selection options. Conditional formatting is set such that if the value of my:field1 is "a", the control has a red background color.

 <select class="xdListBox xdBehavior_Select" title="" style="WIDTH: 130px" size="3" xd:binding="my:field1" xd:boundProp="value" value="a" xd:xctname="ListBox" xd:CtrlId="CTRL1" tabIndex="0">
     <xsl:attribute name="style">WIDTH: 130px;<xsl:choose>
             <xsl:when test="my:field1 = &quot;a&quot;">BACKGROUND-COLOR: #ff0000; caption: Rule 1</xsl:when>
         </xsl:choose>
     </xsl:attribute>
     <xsl:attribute name="value">
         <xsl:value-of select="my:field1"/>
     </xsl:attribute>
     <xsl:choose>
         <xsl:when test="function-available('xdXDocument:getDOM')">
         <option/>
             <xsl:variable name="val" select="my:field1"/>
                 <xsl:if test="not(my:group1/my:group2[my:field2=$val] or $val='')">
                     <option selected="selected">
                         <xsl:attribute name="value">
                             <xsl:value-of select="$val"/>
                         </xsl:attribute>
                         <xsl:value-of select="$val"/>
                     </option>
                 </xsl:if>
             <xsl:variable name="items">
                 <xsl:copy-of select="my:group1/my:group2"/>
             </xsl:variable>
             <xsl:variable name="uniqueItems" select="msxsl:node-set($items)/*[not(my:field3 = preceding::my:group2/my:field3)]"/>
             <xsl:for-each select="$uniqueItems">
                 <option>
                     <xsl:attribute name="value">
                         <xsl:value-of select="my:field2"/>
                     </xsl:attribute>
                     <xsl:if test="$val=my:field2">
                         <xsl:attribute name="selected">selected</xsl:attribute>
                     </xsl:if>
                     <xsl:value-of select="my:field3"/>
                 </option>
             </xsl:for-each>
         </xsl:when>
         <xsl:otherwise>
             <option>
                 <xsl:value-of select="my:field1"/>
             </option>
         </xsl:otherwise>
     </xsl:choose>
 </select>

The following example is a list box control that looks up the selection options from a repeating group in a secondary data source called "UserNameList". Conditional formatting is set such that if the value of my:field1 is "a", the control has a red background color.

 <select class="xdListBox xdBehavior_Select" title="" style="WIDTH: 130px" size="3" xd:binding="my:field1" xd:boundProp="value" value="a" xd:xctname="ListBox" xd:CtrlId="CTRL1" tabIndex="0">
     <xsl:attribute name="style">WIDTH: 130px;<xsl:choose>
             <xsl:when test="my:field1 = &quot;a&quot;">BACKGROUND-COLOR: #ff0000; caption: Rule 1</xsl:when>
         </xsl:choose>
     </xsl:attribute>
     <xsl:attribute name="value">
         <xsl:value-of select="my:field1"/>
     </xsl:attribute>
     <xsl:choose>
         <xsl:when test="function-available('xdXDocument:getDOM')">
             <option/>
             <xsl:variable name="val" select="my:field1"/>
             <xsl:if test="not(xdXDocument:getDOM(&quot;UserNameList&quot;)/dfs:myFields/dfs:dataFields/dfs:UserNameList[@E-mail_Address=$val] or $val='')">
                 <option selected="selected">
                     <xsl:attribute name="value">
                         <xsl:value-of select="$val"/>
                     </xsl:attribute>
                     <xsl:value-of select="$val"/>
                 </option>
             </xsl:if>
             <xsl:for-each select="xdXDocument:getDOM(&quot;UserNameList&quot;)/dfs:myFields/dfs:dataFields/dfs:UserNameList">
                 <option>
                     <xsl:attribute name="value">
                         <xsl:value-of select="@E-mail_Address"/>
                     </xsl:attribute>
                     <xsl:if test="$val=@E-mail_Address">
                         <xsl:attribute name="selected">selected</xsl:attribute>
                     </xsl:if>
                     <xsl:value-of select="@Last_Name"/>
                 </option>
             </xsl:for-each>
         </xsl:when>
         <xsl:otherwise>
             <option>
                 <xsl:value-of select="my:field1"/>
             </option>
         </xsl:otherwise>
     </xsl:choose>
 </select>