kwilliams
06-16-2008, 01:00 PM
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):
<%
//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
}
%>
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:
<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 -->
And maybe the XSLT code could look like this?
<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>
Any help would be appreciated. Thanks.
<%
//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
}
%>
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:
<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 -->
And maybe the XSLT code could look like this?
<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>
Any help would be appreciated. Thanks.