Can not generate a blank option on a drop down menu - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Can not generate a blank option on a drop down menu

pmoralespmorales Posts: 3Member
I have a script that generates the days of a month once you select a month and checks to see if the month is a leapyear once you select a year. I can't get the day drop down list to have a blank option on top of the 1 once a month or year has been selected. So lets say you select a date and then you decide to not enter a date you can't make the day dropdown menu blank because there is no blank option to choose. Can someone tell me how I can enter a blank option into my day dropdown menu?




Untitled Document







1
2
3
4
5
6
7
8
9
10
11
12

/



/


1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012





function GetDaysInMonth(iMonth, iYear)
{
var dPrevDate = new Date(iYear, iMonth, 0);
return dPrevDate.getDate();
}

var mylength
var myprevlength
var daycounter
var prevdaycounter
var TheYear
var TheDay
var TheMonth


function writedays()
{
var TheYear=document.all.Year.value
var TheDay=document.all.Day.value
var TheMonth=document.all.Month.value
var myoday=document.all.CD.value
if (TheDay!="")
{
myoday=TheDay
}
if((TheMonth !=="" && TheYear!=="") || (TheMonth !==null && TheYear !==null))
{

daycounter=1
prevdaycounter=0
mylength=GetDaysInMonth(TheMonth, TheYear)
myprevlength=document.all.Day.options.length
var Daysarray=new Array(mylength)

if (document.all.Day.options.length>0)
{
document.all.Day.length=0
while(prevdaycounter


writedays()




Sign In or Register to comment.