Php + js + mysql-like webQQ-& amp; lt; 3 & amp; gt; month days change with month. During registration, the number of days of the month changes with the change of the month. this small function is used in many places! The number of days in May changes with the month. when the PHP code [php] s is registered, the number of days in the month changes with the change of the month when the birthday is filled in, this small function is used in many places!
<5> The number of days of a month changes with the month
PHP code
[Php]
// Onchange event For ($ I = 1; $ I <= 12; $ I ++){Echo"";Echo $ I;Echo"";}?>Month
For ($ I = 1; $ I <= 31; $ I ++){Echo"";Echo $ I;Echo"";}?>Day
// Onchange event For ($ I = 1; $ I <= 12; $ I ++){Echo"";Echo $ I;Echo"";}?>Month
For ($ I = 1; $ I <= 31; $ I ++){Echo"";Echo $ I;Echo"";}?>Day
Js code
[Javascript]
Function monthDays (month)
{
Var xmlhttp;
If (window. XMLHttpRequest)
{// Code for IE7 +, Firefox, Chrome, Opera, Safari
Xmlhttp = new XMLHttpRequest ();
}
Else
{// Code for IE6, IE5
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Xmlhttp. onreadystatechange = function ()
{
If (xmlhttp. readyState = 4 & xmlhttp. status = 200)
{
If (month = 2)
{
Document. getElementById ("day"). length = 0; // first clear the select option of the number of days of the month
For (I = 1; I <= 29; I ++)
{
Document. getElementById ("day"). options. add (new Option (I, I ));
}
}
Else if (month = 4 | month = 6 | month = 9 | month = 11)
{
Document. getElementById ("day"). length = 0;
For (I = 1; I <= 30; I ++)
{
Document. getElementById ("day"). options. add (new Option (I, I ));
}
}
Else
{
Document. getElementById ("day"). length = 0;
For (I = 1; I <= 31; I ++)
{
Document. getElementById ("day"). options. add (new Option (I, I ));
}
}
}
}
Xmlhttp. open ("GET", "index. php", true );
Xmlhttp. send ();
}
Function monthDays (month)
{
Var xmlhttp;
If (window. XMLHttpRequest)
{// Code for IE7 +, Firefox, Chrome, Opera, Safari
Xmlhttp = new XMLHttpRequest ();
}
Else
{// Code for IE6, IE5
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Xmlhttp. onreadystatechange = function ()
{
If (xmlhttp. readyState = 4 & xmlhttp. status = 200)
{
If (month = 2)
{
Document. getElementById ("day"). length = 0; // first clear the select option of the number of days of the month
For (I = 1; I <= 29; I ++)
{
Document. getElementById ("day"). options. add (new Option (I, I ));
}
}
Else if (month = 4 | month = 6 | month = 9 | month = 11)
{
Document. getElementById ("day"). length = 0;
For (I = 1; I <= 30; I ++)
{
Document. getElementById ("day"). options. add (new Option (I, I ));
}
}
Else
{
Document. getElementById ("day"). length = 0;
For (I = 1; I <= 31; I ++)
{
Document. getElementById ("day"). options. add (new Option (I, I ));
}
}
}
}
Xmlhttp. open ("GET", "index. php", true );
Xmlhttp. send ();
}
This effect still uses the Ajax partial refresh technology. You are welcome to exchange and learn. (To be continued)
From wyzhangchengjin123
Success! The number of days in March changes with the month. PHP code [php] s...