How to set active a button in xslt? -


i have code in xslt selecting 2 values using buttons.i need check value , set active corresponding button.here code

 <ul class="switch">  <li class="private-btn">  <xsl:if test="library:requestquerystring('at') = 'privat'">  here need active btn code   </xsl:if>  <input type="button" class="privat" value="privat"></input>   </li>  <li class="business-btn">  <xsl:if test="library:requestquerystring('at') = 'erhverv'">     here need active btn code  </xsl:if> <input type="button" class="privat" value="erhverv"></input>  </li> </ul> 

can help?

if understand correctly, want conditionally set disabled html attribute (and possibly other attributes) on button.

you can conditionally add attribute so:

<input type="button" class="privat" value="erhverv">   <xsl:choose>     <xsl:when test="library:requestquerystring('at') = 'privat'">       <xsl:attribute name="disabled">disabled</xsl:attribute>     </xsl:when>     <xsl:otherwise>       ... other attribute here etc.     </xsl:otherwise>   </xsl:choose> </input> 

since seems need reuse logic, can refactor enabled / attribute state generation call template, so:

  <xsl:template name="setactivestate">     <xsl:param name="state"></xsl:param>     <xsl:choose>       <xsl:when test="$state='true'">         <xsl:attribute name="disabled">disabled</xsl:attribute>       </xsl:when>       <xsl:otherwise>...</xsl:otherwise>     </xsl:choose>   </xsl:template> 

and call so:

<input type="button" class="privat" value="erhverv">   <xsl:call-template name="setactivestate">     <xsl:with-param name="state"                      select="library:requestquerystring('at') = 'privat'">     </xsl:with-param>   </xsl:call-template> </input> 

... same <input type="button" class="privat" value="privat"></input>


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -