...

View Full Version : Populating current year and following year in select drop-down



Errica
02-14-2007, 04:48 PM
How can this be modified so that I do not have to hard-code '07 and '08?



<select class="rez" id="Year" name="Year">
<option value=07>Year</option>
<option value=2007>2007</option>
<option value=2008>2008</option>
</select>

angst
02-14-2007, 05:43 PM
wouldn't it be better to use asp or php for this?

Errica
02-14-2007, 05:54 PM
I can use php if that helps?

angst
02-14-2007, 06:10 PM
ok,
try this:



<?
echo "<select class='rez' id='Year' name='Year'>\n";
echo "<option value='" . (Date('Y') -1) . "'>" . (Date('Y') -1) . "</option>\n";
echo "<option value='" . Date('Y') . "' SELECTED>" . Date('Y') . "</option>\n";
echo "<option value='" . (Date('Y') + 1) . "'>" . (Date('Y') + 1) . "</option>\n";
echo "<option value='" . (Date('Y') + 2) . "'>" . (Date('Y') + 2) . "</option>\n";
echo "</select>\n";
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum