基于月份和年份下拉列表显示日期-php ajax
您好,我有下面的代码,它将根据月份和年份的下拉列表显示日期 index.html基于月份和年份下拉列表显示日期-php ajax,php,ajax,Php,Ajax,您好,我有下面的代码,它将根据月份和年份的下拉列表显示日期 index.html 函数showDate(){ var str=document.getElementById(“mymonth”).value; var str1=document.getElementById(“myyear”).value; 如果(str==0){//如果没有从第一个下拉列表中选择任何内容 document.getElementById(“txtHint”).innerHTML=“”; 返回; } if(wi
函数showDate(){
var str=document.getElementById(“mymonth”).value;
var str1=document.getElementById(“myyear”).value;
如果(str==0){//如果没有从第一个下拉列表中选择任何内容
document.getElementById(“txtHint”).innerHTML=“”;
返回;
}
if(window.XMLHttpRequest){
//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}
否则{
//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数(){
if(this.readyState==4&&this.status==200){
document.getElementById(“txtHint”).innerHTML=this.responseText;
}
}
open(“GET”、“getdate.php?selectedmonth=“+str+””和selectedyear=“+str1,true);
xmlhttp.send();
}
选择月份
一月
二月
雨衣
四月
教育与工业应用数学组织
六月
七月
八月
九月
十月
十一月
十二月
选择年份:
2016
2017
按月/年划分的日期组
getdate.php
向默认选择选项添加值属性
<option value="">Select Month</option>
<option value="">Select Year:</option>
将时区添加到PHP文件中,在文件的开头,如下
<?php
$selectedmonth = intval($_GET['selectedmonth']);
$selectedyear = intval($_GET['selectedyear']);
$month = "$selectedmonth";
$year = "$selectedyear";
$start_date = "01-".$month."-".$year;
$start_time = strtotime($start_date);
$end_time = strtotime("+1 month", $start_time);
echo "<table border='1'>";
for($i=$start_time; $i<$end_time; $i+=86400)
{
$list = date('d M Y (D)', $i);
echo "<tr><td>";
echo $list;
echo "</td>";
echo "<td> </td>";
echo "</tr>";
}
echo "</table>";
?>
<option value="">Select Month</option>
<option value="">Select Year:</option>
if(str == '' || str1 == ''){
return;
}
//Your Ajax goes here...
date_default_timezone_set("Asia/Kolkata"); //Change your timezone accordingly. Here it's set to Kolkatta, India.