Here is a simple example of how to use a for loop to generate <option>'s for a select menu. This example also shows how to make a default <option> be selected:
// write one selected option
document.write('<option value="" selected="selected">Day</option>');
// var num=1, as long as num is less than or equal to 31, num will increment
for(var num=1; num<=31; num++)
// write 31 options, with num as the value and text displayed.
// should add name attribute for server side
document.write('<option value="' + num + '">' + num + '</option>');