Home > php教程 > php手册 > php+js+mysql设计的仿webQQ-<3>月份天数随月份改变

php+js+mysql设计的仿webQQ-<3>月份天数随月份改变

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:49:04
Original
1118 people have browsed it

注册时,在填写生日的时候,月份的天数会随着月份的改变而改变,这个小功能在很多的地方都用得到哦!

月份天数随月份改变

PHP代码

[php]
月 
日 


Js代码

[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;     //先把月份天数的select的option清空  
             for(i=1;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                      { 
                        document.getElementById("day").options.add(new Option(i,i)); 
                     } 
               } 
        else 
          { 
              document.getElementById("day").length=0; 
                  for(i=1;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;     //先把月份天数的select的option清空
             for(i=1;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                      {
                        document.getElementById("day").options.add(new Option(i,i));
                     }
               }
        else
          {
              document.getElementById("day").length=0;
                  for(i=1;i                      {
                        document.getElementById("day").options.add(new Option(i,i));
                     }
          }  
  
    }
  }
xmlhttp.open("GET","index.php",true);
xmlhttp.send();
}
 
这种效果还是用到Ajax的局部刷新技术,欢迎大家交流学习。(未完待续)

 

摘自 wyzhangchengjin123

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
JS jump to PHP page stuck
From 1970-01-01 08:00:00
0
0
0
Help js code mixed with php code usage exception
From 1970-01-01 08:00:00
0
0
0
running js code in php
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template