I have a loop that is creating a drop down of 31 days. days 1-9 need a zero prepended onto them such as 01-09 to make sure sql server does not throw an error. I rather do this in the jquery then later on.
for (i = 1; i < 32; i++)
{
if (i > 9)
{
$('#daypicker').append($('<option />').val(i).html(i));
} else {
$('#daypicker').append($('<option />').val(i).html(i));
}
}
so I need 01-31, not 1-31.
Simplest answer – inside the loop:
then use
strinstead ofiin the.val()and.html()calls, having removed theif / elseclause.