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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl variable from <select>

Status
Not open for further replies.

ozane

Technical User
Feb 3, 2005
57
TR
hi,
i am populating a html select from xml using xslt. what i need is assigning the selected value from <select> to a variable.
which test shloul i do to check if which option is selected?
here is my selector
Code:
<select id="SRSSelector">
  <optgroup label="Available SRS">
    <xsl:for-each select="Layer/Page">
        <option><xsl:value-of select="@SRS"/></option>
    </xsl:for-each>					
  </optgroup>
</select>

Code:
<xsl:variable name="Vatt">
?...........?	
</xsl:variable>
 
<select id="SRSSelector">
<optgroup label="Available SRS">
<xsl:for-each select="Layer/Page">
<xsl:varaible name="Vatt" select="@SRS"/>
</xsl:for-each>
</optgroup>
</select>
 
Your select should have a "name" attribute and your options should have values. If you have some parameter passed to your XSL called SRSValue you could do this:
Code:
<select name="SRSSelector">
  <optgroup label="Available SRS">
    <xsl:for-each select="Layer/Page">
      <option value="{@SRS}>
        <xsl:if test="@SRS = $SRSValue>
          <xsl:attribute name="selected">selected</xsl:attribute>
        </xsl:if>
        <xsl:value-of select="@SRS"/>
      </option>
    </xsl:for-each>                    
  </optgroup>
</select>
You have to pass this parameter to the stylesheet when the form is submitted

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top