|
↑
Forms >>>
This script helps to insure the integrity of the date entered in drop-down menus. Dates, such as Feb 31st can't be selected. Today's date is automatically selected.
Add the below code to the <body> section of your page:
<script
language="javascript"
type="text/javascript">
Now
=
new
Date();
NowDay
=
Now.getDate();
NowMonth
=
Now.getMonth();
NowYear
=
Now.getYear();
if
(NowYear
<
2000)
NowYear +=
1900;
function
DaysInMonth(WhichMonth,
WhichYear)
{
var
DaysInMonth =
31;
if
(WhichMonth
==
"Apr"
||
WhichMonth ==
"Jun"
||
WhichMonth ==
"Sep"
||
WhichMonth ==
"Nov")
DaysInMonth =
30;
if
(WhichMonth
==
"Feb"
&&
(WhichYear/4)
!=
Math.floor(WhichYear/4))
DaysInMonth =
28;
if
(WhichMonth
==
"Feb"
&&
(WhichYear/4)
==
Math.floor(WhichYear/4))
DaysInMonth =
29;
return
DaysInMonth;
}
function
ChangeOptionDays(Which)
{
DaysObject
=
eval("document.Form1."
+
Which +
"Day");
MonthObject
=
eval("document.Form1."
+
Which +
"Month");
YearObject
=
eval("document.Form1."
+
Which +
"Year");
Month
=
MonthObject[MonthObject.selectedIndex].text;
Year
=
YearObject[YearObject.selectedIndex].text;
DaysForThisSelection
=
DaysInMonth(Month,
Year);
CurrentDaysInSelection
=
DaysObject.length;
if
(CurrentDaysInSelection
>
DaysForThisSelection)
{
for
(i=0;
i<(CurrentDaysInSelection-DaysForThisSelection);
i++)
{
DaysObject.options[DaysObject.options.length
-
1]
=
null
}
}
if
(DaysForThisSelection
>
CurrentDaysInSelection)
{
for
(i=0;
i<(DaysForThisSelection-CurrentDaysInSelection);
i++)
{
NewOption
=
new
Option(DaysObject.options.length
+
1);
DaysObject.options[DaysObject.options.length]
=
NewOption;
}
}
if
(DaysObject.selectedIndex
<
0)
DaysObject.selectedIndex
==
0;
}
function
SetToToday(Which)
{
DaysObject
=
eval("document.Form1."
+
Which +
"Day");
MonthObject
=
eval("document.Form1."
+
Which +
"Month");
YearObject
=
eval("document.Form1."
+
Which +
"Year");
YearObject[0].selected
=
true;
MonthObject[NowMonth].selected
=
true;
ChangeOptionDays(Which);
DaysObject[NowDay-1].selected
=
true;
}
function
WriteYearOptions(YearsAhead)
{
line
=
"";
for
(i=0;
i<YearsAhead;
i++)
{
line
+=
"<OPTION>";
line
+=
NowYear +
i;
}
return
line;
}
function
Go()
{
SetToToday('FirstSelect');
}
window.onload=Go;
</script>
<nobr>
<FORM
name="Form1">
<SELECT
name="FirstSelectDay">
<OPTION>1
<OPTION>2
<OPTION>3
<OPTION>4
<OPTION>5
<OPTION>6
<OPTION>7
<OPTION>8
<OPTION>9
<OPTION>10
<OPTION>11
<OPTION>12
<OPTION>13
<OPTION>14
<OPTION>15
<OPTION>16
<OPTION>17
<OPTION>18
<OPTION>19
<OPTION>20
<OPTION>21
<OPTION>22
<OPTION>23
<OPTION>24
<OPTION>25
<OPTION>26
<OPTION>27
<OPTION>28
<OPTION>29
<OPTION>30
<OPTION>31
</SELECT>
<SELECT
name="FirstSelectMonth"
onChange="ChangeOptionDays('FirstSelect')">
<OPTION>Jan
<OPTION>Feb
<OPTION>Mar
<OPTION>Apr
<OPTION>May
<OPTION>Jun
<OPTION>Jul
<OPTION>Aug
<OPTION>Sep
<OPTION>Oct
<OPTION>Nov
<OPTION>Dec
</SELECT>
<SELECT
name="FirstSelectYear"
onChange="ChangeOptionDays('FirstSelect')">
<SCRIPT
language="JavaScript">
document.write(WriteYearOptions(50));
</SCRIPT>
</SELECT>
</FORM>
</nobr>
|
↓ http://www.cashadvance-loans.net/california/cash-advance-oxnard-ca/ . Bitcoin Dice Site
|