Posted by Tim Burgan on 01/19/05 08:19
Hello,
I have a for loop to create a HTML combo box that displays the 10 year
values, starting from today's year and incrementing until 10 years it
reached.
The output of the loop to the browser is weird.
If anyone has time, can you please let me know where I screwed up?
Here's my loop:
echo '<select name="expire_year" size="1">';
$numbOfYears = 10;
for ( $i = 0; $i < $numbOfYears; $i++ )
{
echo '<option value="'. $today_year + $i .'"';
if ( $_SESSION['createStudent_expireYear'] == $today_year + $i )
{
echo ' selected="selected"';
}
echo '>'. $today_year + $i .'</option>';
}
echo '</select>';
And here's the bung output:
<select name="expire_year" size="1">
0"0</option>
1" selected="selected"1</option>
2"2</option>
3"3</option>
4"4</option>
5"5</option>
6"6</option>
7"7</option>
8"8</option>
9"9</option>
</select>
And here's what I was expecting:
<select name="expire_year" size="1">
<option value="2005">2005</option>
<option value="2006" selected="selected">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
</select>
Thanks for your time and assistance
Tim
[Back to original message]
|