Add jquery files for debugging
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Script src = "jquery. js"> </script>
<Script>
$ (Function (){
$ ('# Year'). change (function (){
If (ifLeapYear ($ (this). val ()))
{
If ($ ('# month'). val () = 2 & $ (' # Day'). children (). length = 29)
{
$ ('# Day'). append (' <option value = "29"> 29 </option> ');
}
} Else
{
If ($ ('# month'). val () = 2 & $ (' # Day'). children (). length = 30)
{
$ ('# Day: last-child'). remove ();
}
}
});
$ ('# Month'). change (function (){
Var thisValue = $ (this). val ();
Var dayValue = $ ('# Day'). val ();
Var month1 = ['4', '6', '9', '11'];
Optional ('day'hangzhou.html ('<option value = "">-select-</option> ');
Var day = '';
If (thisValue = '')
{
Return false;
}
If ($. inArray (thisValue, month1 )! =-1)
{
Day = setDay (30 );
$ ('# Day'). append (day );
} Else if ($ (this). val () = '2 ')
{
If ($ ('# year'). val ()! = ''& IfLeapYear ($ ('# year'). val ()))
{
Day = setDay (29 );
} Else
{
Day = setDay (28 );
}
$ ('# Day'). append (day );
} Else
{
Day = setDay (31 );
$ ('# Day'). append (day );
}
$ ('# Day'). find ('option [value =' + dayValue + ']'). attr ('selected', true );
});
})
Function setDay (day)
{
Var dayInfo = '';
For (var I = 1; I <= day; I ++)
{
DayInfo + = '<option value = "' + I + '">' + I + '</option> ';
}
Return dayInfo;
}
Function ifLeapYear (year)
{
If (year % 4 = 0 & amp; year % 100! = 0) | year % 400 = 0)
{
Return true;
} Else
{
Return false;
}
}
</Script>
<Select id = "year"> <option value = "">-select-</option>
<? Php for ($ I = 1980; $ I <2012; $ I ++) {?>
<Option value = "<? Php echo $ I?> "> <? Php echo $ I?> </Option>
<? Php }?>
</Select> year
<Select id = "month"> <option value = "">-select-</option>
<? Php for ($ I = 1; $ I <= 12; $ I ++) {?>
<Option value = "<? Php echo $ I?> "> <? Php echo $ I?> </Option>
<? Php }?>
</Select> month
<Select id = "day"> <option value = "">-select-</option> </select> day