Hi there,
I write out a page and with one external js, the function are performing but i found that i facing this error message in my IE7, “object doesn’t support this property or method”, my page are like below:
[QUOTE]
<html>
<script type=”text/javascript” src=”../Include/homePage.js”>
</script>
<body onLoad=”displayCurrentMonth()”>
<table width=”360″ border=”1″>
<tr>
<td colspan=”3″ align=”center”>
<input name=”btnPrevious” type=”button” id=”btnPrevious” value=”<<” onClick=”previousMonth()”>
<strong>Monthly Seat Availability</strong>
<input name=”btnNext” type=”button” id=”btnNext” value=”>>” onClick=”nextMonth()”></td>
</tr>
<tr>
<td colspan=”3″ align=”center”><label></label><div id=”MonthYears”></div>
<input type=”hidden” name=”hiddenMonth” id=”hiddenMonth” name=”hiddenMonth” value=””>
<input type=”hidden” name=”hiddenYears” id=”hiddenYears” name=”hiddenYears” value=””></td>
</tr>
<tr>
<td width=”180″ colspan=”1″> </td>
<td width=”180″> </td>
</tr>
</table>
</body>
</html>
and my js is like below:
[QUOTE]
// JavaScript Document
function displayCurrentMonth()
{
var d=new Date();
var y=new Date();
var month=new Array(12)
month[0]=”January”
month[1]=”February”
month[2]=”March”
month[3]=”April”
month[4]=”May”
month[5]=”June”
month[6]=”July”
month[7]=”August”
month[8]=”September”
month[9]=”October”
month[10]=”November”
month[11]=”December”
correctMonth = month[d.getMonth()];
correctM = d.getMonth();
correctYears = y.getFullYear();
correctY = parseInt(y.getFullYear());
combineDate = correctMonth + “-” + correctYears;
document.getElementById(“MonthYears”).innerHTML= combineDate;
document.getElementById(“hiddenMonth”).value = correctM;
document.getElementById(“hiddenYears”).value = correctY;
//document.write(“The years is” + y);
}
function previousMonth()
{
var month=new Array(12)
month[0]=”January”
month[1]=”February”
month[2]=”March”
month[3]=”April”
month[4]=”May”
month[5]=”June”
month[6]=”July”
month[7]=”August”
month[8]=”September”
month[9]=”October”
month[10]=”November”
month[11]=”December”
var nowMonth = parseInt(document.getElementById(“hiddenMonth”).value);
var nowYears = parseInt(document.getElementById(“hiddenYears”).value);
if(month[nowMonth] == month[0])
{
var nowMonth = 11;
var nextMonth = month[nowMonth];
var nextYears = nowYears-1;
var hiddenNowM = nowMonth;
var hiddenNowY = nextYears;
var nextCombined = nextMonth + “-” + nextYears;
document.getElementById(“MonthYears”).innerHTML = nextCombined;
document.getElementById(“hiddenMonth”).value = hiddenNowM;
document.getElementById(“hiddenYears”).value = hiddenNowY;
}
else
{
var nextMonth = month[nowMonth – 1];
var nextYears = nowYears;
var hiddenNowM = nowMonth – 1;
var hiddenNowY = nextYears;
var nextCombined = nextMonth + “-” + nextYears;
document.getElementById(“MonthYears”).innerHTML = nextCombined;
document.getElementById(“hiddenMonth”).value = hiddenNowM;
document.getElementBtId(“hiddenYears”).value = hiddenNowY;
}
}
function nextMonth()
{
var month=new Array(12)
month[0]=”January”
month[1]=”February”
month[2]=”March”
month[3]=”April”
month[4]=”May”
month[5]=”June”
month[6]=”July”
month[7]=”August”
month[8]=”September”
month[9]=”October”
month[10]=”November”
month[11]=”December”
var nowMonth = parseInt(document.getElementById(“hiddenMonth”).value);
var nowYears = parseInt(document.getElementById(“hiddenYears”).value);
if(month[nowMonth] == month[11])
{
var nowMonth = 0;
var nextMonth = month[nowMonth];
var nextYears = nowYears+1;
var hiddenNowM = nowMonth;
var hiddenNowY = nextYears;
var nextCombined = nextMonth + “-” + nextYears;
document.getElementById(“MonthYears”).innerHTML = nextCombined;
document.getElementById(“hiddenMonth”).value = hiddenNowM;
document.getElementById(“hiddenYears”).value = hiddenNowY;
}
else
{
var nextMonth = month[nowMonth + 1];
var nextYears = nowYears;
var hiddenNowM = nowMonth + 1;
var hiddenNowY = nextYears;
var nextCombined = nextMonth + “-” + nextYears;
document.getElementById(“MonthYears”).innerHTML = nextCombined;
document.getElementById(“hiddenMonth”).value = hiddenNowM;
document.getElementBtId(“hiddenYears”).value = hiddenNowY;
}
}
The function is wok well as what i want, but i dun know why such error will appear, anyone have idea?
Thanks and best regard
Kc