Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Default option in a select control 1

Status
Not open for further replies.

Kalisto

Programmer
Feb 18, 2003
997
GB
Trying to set the default option that appears in a select control, all I get is errors or a blank page at the moment, so what obvious mistake am I making?

Code:
<!-- Fill in the Drop Down List from the XML Schema-->
<select>
    <xsl:attribute name="name">ddlOrganisationCountry</xsl:attribute>
    <xsl:for-each select="document('[URL unfurl="true"]http://localhost/xmlproject/bdefinitions.xsd')/xs:schema/xs:element[/URL][@name='country']//xs:enumeration">
        <option value="{@value}">
            <xsl:value-of select="@value"/>
        </option>
    </xsl:for-each>
    <xsl:if '@value'="United Kingdom">
        <xsl:attribute name="selected">United Kingdom</xsl:attribute>
    </xsl:if>
</select>
 
Code:
<!-- Fill in the Drop Down List from the XML Schema-->
<select>
  <xsl:attribute name="name">ddlOrganisationCountry</xsl:attribute>
  <xsl:for-each select="document('[URL unfurl="true"]http://localhost/xmlproject/bdefinitions.xsd')/xs:schema/xs:element[/URL][@name='country']//xs:enumeration">
    <option value="{@value}">
      <xsl:if test="@value='United Kingdom'">
        <xsl:attribute name="selected">selected</xsl:attribute>
      </xsl:if>
      <xsl:value-of select="@value"/>
    </option>
  </xsl:for-each>
</select>
 
Cheers, any more stars from me and you'll be running the pentagon..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top