I'm very, very new at javascript so please be patient with me. I'm trying to write a for loop that will generate links for me, depending on the month. When I try to run the script firebug keeps giving me this error:
missing ] in index expression
Month[11] = new Array(2)\n
Can anyone help me?
Here is the code I'm trying to run:
-JTBorton
Another Day, Another Disaster
missing ] in index expression
Month[11] = new Array(2)\n
Can anyone help me?
Here is the code I'm trying to run:
Code:
<script language="javascript">
CurrentMonth = "April"
CalSrc = "http://[DOMAIN...]/Calendars/BeaumontYSACalendar"
Month = new Array(13)
Month[0] = new Array(2)
Month[0][0] = "January"
Month[0][1] = "Jan09.html"
Month[1] = new Array(2)
Month[1][0] = "February"
Month[1][1] = "Feb09.html"
Month[2] = new Array(2)
Month[2][0] = "March"
Month[2][1] = "Mar09.html"
Month[3] = new Array(2)
Month[3][0] = "April"
Month[3][1] = "Apr09.html"
Month[4] = new Array(2)
Month[4][0] = "May"
Month[4][1] = "May09.html"
Month[5] = new Array(2)
Month[5][0] = "June"
Month[5][1] = "Jun09.html"
Month[6] = new Array(2)
Month[6][0] = "July"
Month[6][1] = "Jul09.html"
Month[7] = new Array(2)
Month[7][0] = "August"
Month[7][1] = "Aug09.html"
Month[8] = new Array(2)
Month[8][0] = "September"
Month[8][1] = "Sep09.html"
Month[9] = new Array(2)
Month[9][0] = "October"
Month[9][1] = "Oct09.html"
Month[10] = new Array(2)
Month[10][0] = "November"
Month[10[1] = "Nov09.html"
Month[11] = new Array(2)
Month[11][0] = "December"
Month[11][1] = "Dec09.html"
//Link Format:
// | <a href=" [HTML SOURCE]Mmm-YY.html "> [MONTH NAME] </a> |
// Where [HTML SOURCE] = Everything in the URL preceding the final extension of each months page URL.
// Example Source: http://[DOMAIN...]/Calendars/BeaumontYSACalendarMar-09.html
for(i=0;i<12;++i) {
if (Month[i][0]==CurrentMonth) {
// If the month variable matches the current month, highlight the text in red, but don't make a link
document.write('<font color="red"><strong>' + Month[i][0] + '</strong></font> | ')
if (i==5) {
document.write("<br />") // Insert a line break after June
}
} else {
// If the month variable does not match the current month, produe a link to that month calendar
document.write('<a href="' + CalSrc + Month[i][1] + '">' + Month[i][0] + '</a> | ')
if (i==5) {
document.write("<br />") // Insert a line break after June
}
}
}
//
</script>
-JTBorton
Another Day, Another Disaster