I have the following JavaScript loop within an old ASP page that loops through the years from a starting year variable (1900) to the ending year variable (1990):
I'm wondering if I can do the same thing within XSLT with the use of a for:each method. I've been able to create the same variables with XSLT math, like this:Code:<% //Year array var strCurrDate = new Date(); strCurrYear = strCurrDate.getYear(); strVotingYear = strCurrYear - 18;//youngest voter year strDiffYear = strVotingYear - 1900;//years from youngest minus oldest voters //Voter year loop var LoopNumber = strDiffYear; for (i=1900;i<=strVotingYear;i++){ Response.Write(i + "<br />");//test Response.Write("<option value='" + i + "'>" + i + "</option>");//test } %>
And maybe the XSLT code could look like this?Code:<xsl:param name="current_year" select="''" /> <xsl:param name="voting_year" select="$current_year - 18" /><!-- youngest voter year --> <xsl:param name="diff_year" select="$voting_year - 1900" /><!-- years from youngest minus oldest voters -->
Any help would be appreciated. Thanks.Code:<select id="year" name="selectYear"> <option value="" selected="">- Year -</option> <xsl:for-each select=""> <!-- ???Not sure what to do here??? --> <option value="???"><xsl:value-of select="???" /></option> </xsl:for-each> </select>


Reply With Quote
utput method="xml" encoding="UTF-8" indent="yes"/>
Bookmarks