Php + js + mysql-like webQQ-& lt; 3 & gt; month-day changes with month _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.