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!

default option in html select

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
Hi all,

this is driving me crazy. I am trying to do two things.
firstly i am trying to get a html select to show a default option. I have seen this post:
but i can't get it to work.

This is what i have got at the moment:

<select name="CountryID">
<xsl:for-each select="//FormContent/countries/country">
<option value="{@id}"><xsl:value-of select="."/>
<xsl:if test="'54911DA6-F0FA-237B-A411FE65AB85AAE4'=$Country">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
</option>
</xsl:for-each>
</select>

2ndly i am trying to pass a param called Country into the xslt from a server side page, and i want to test to see if the passed param matches the value in my id attribute. when i try to do the comparison against the xml value it fails that's why i have the hardcoded value in there at the moment.

any ideas?

TIA

Tony
 
Attribute has to be directly after the node it refers to:
Code:
<select name="CountryID">
  <xsl:for-each select="//FormContent/countries/country">
    <option value="{@id}">
      <xsl:if test="'54911DA6-F0FA-237B-A411FE65AB85AAE4'=$Country">
        <xsl:attribute name="selected">selected</xsl:attribute>
      </xsl:if>
      <xsl:value-of select="."/>
    </option>
  </xsl:for-each>
</select>

Jon

"I don't regret this, but I both rue and lament it.
 
thanks for that. i think i tried everything else, but didn't even thinnk to try and change the order in which they would be displayed!

Have a star

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top