我有两个php页面。
我正在使用XMLHttRequest发送月份值并获取该月的日期。
第一页PHP
<html>
<head>
<script type="text/javascript">
function showMonth(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
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)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","showmonthCalender.php?month="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select name="month" class="default" tabindex="2" onChange="showMonth(this.value)">
<option value="01">JANUARY</option>
<option value="02">FEBRUARY</option>
<option value="03">MARCH</option>
<option value="04">APRIL</option>
<option value="05">MAY</option>
<option value="06">JUNE</option>
<option value="07">JULY</option>
<option value="08">AUGUST</option>
<option value="09">SEPTEMBER</option>
<option value="10">OCTOBER</option>
<option value="11">NOVEMBER</option>
<option value="12">DECEMBER</option>
</select>
</form>
<div id="txtHint">display here</div>
</body>
</html>
第二个PHP文件(showmonthCalender.php)
<?php
$monthfetch = $_GET['month'];
$carry = "<div class='clear'></div>";
if ($monthfetch == '01' || $monthfetch == '03' || $monthfetch == '05' || $monthfetch == '07' || $monthfetch == '08' || $monthfetch == '10' || $monthfetch == '12')
{
for($i=01; $i<32; $i++)
{
$d = $i;
$y = date('Y');
$theDate = $y.'-'.$monthfetch.'-'.$d;
$day = date("l", mktime(0, 0, 0, $monthfetch, $d, $y));
$carry = $carry . "<div class='dateHolder'>
<div class='date'>
<div class='valueHoliday'>
$d
</div>
</div>
<div class='day'>
<div class='valueHoliday'>
$day
</div>
</div>
<div class='clear'></div>";
}
echo "$carry";
}
?>
出于测试目的,我只选择有31天的月份。但是当我从第一个php文件中选择一个月时,什么都没有显示出来。我无法解决这个问题。
需要帮助。