I'm working on a calendar that works well in all points except one. I found the code online and modified it to fit my needs. One of my mods isn't working. I'm trying to make it display the chosen month under the drop down box but I'm getting and "Element MONTH_VAL is undefined in FORM" error. It seems to be defined to me but I could be missing something obvious. I'm using cfif's to look for form.month_val which is an integer and then display the month based on which month has been chosen. That's where the error is. I've noted the section that's erroring out in the comments.
I would appreciate any help. Thanks much.
I would appreciate any help. Thanks much.
Code:
<cfoutput>
<div align="center"><h2>#DateFormat(now(), "mmmm, d, yyyy")#</h2></div>
</cfoutput>
</p>
<form name="cal_select" method="get" action="#CGI.script_name#">
<div align="center">To view the events of a particular month:<br />Select Month Number - Enter Year - Click "Go"</div>
<p align="center">
<p align="center">
<input type="submit" name="Go" value="GO" />
<cfoutput>
<select name="month_val">
<option>#month(now())#</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
</cfoutput>
<cfoutput>
<input name="year_val" value="#year(now())#" />
</cfoutput>
<cfoutput>
</cfoutput>
<cfoutput>
</p></form>
<!---Display the selected month--THIS IS WERE THE ERROR IS OCCURING--->
<p>
<div align="center">
<cfif isDefined(form.month_val)>
<cfif form.month_val EQ 1>
January
<cfelseif form.month_val EQ 2>
February
<cfelseif form.month_val EQ 3>
March
<cfelseif form.month_val EQ 4>
April
<cfelseif form.month_val EQ 5>
May
<cfelseif form.month_val EQ 6>
June
<cfelseif form.month_val EQ 7>
July
<cfelseif form.month_val EQ 8>
August
<cfelseif form.month_val EQ 9>
September
<cfelseif form.month_val EQ 10>
October
<cfelseif form.month_val EQ 11>
November
<cfelseif form.month_val EQ 12>
December
</cfif>
</cfif>
</div>
</p>
<!---/Display the selected month -- END ERROR SECTION--->
<form name="caltest1" method="post">
<table border="1" width="100%">
<tr>
<cfloop index="x" from="1" to="7">
<th><span class="style2 style4">#dayOfWeekAsString(x)#</span></th>
</cfloop>
</tr>
</cfoutput>
<cfparam name="year_val" type="integer" default="#DatePart('yyyy', Now())#">
<cfparam name="month_val" type="integer" default="#DatePart('m', Now())#">
<cfset firstOfTheMonth = CreateDate(#year_val#, #month_val#, 1)>
<cfset dow = dayofWeek(firstOfTheMonth)>
<cfset pad = dow - 1>
<cfoutput>
<tr>
</cfoutput>
<cfif pad gt 0>
<cfoutput><td colspan="#pad#"> </td></cfoutput>
</cfif>
<cfset days = daysInMonth(firstOfTheMonth)>
<cfset counter = pad + 1>
<cfloop index="x" from="1" to="#days#">
<cfif x is day(now())>
<cfoutput><td bgcolor="yellow" width="14%"></cfoutput>
<cfelse>
<cfoutput><td width="14%"></cfoutput>
</cfif>
<cfset yourDate = createDate(#year_val#, #month_val#, #x#)>
<cfquery name="Events" datasource="ds_eventsCalendar">
SELECT *
FROM tbl_events
WHERE start_date=#CreateODBCDate(yourDate)#
</cfquery>
<cfoutput>
<div align="center">
<strong>#DateFormat(yourDate, "d")#</strong>
</cfoutput>
<p>
<cfoutput query="Events">
<div align="center">#desc#<br /></div>
<p>
</cfoutput>
</td>
</div>
<cfset counter = counter + 1>
<cfif counter is 8>
<cfoutput></tr>
</cfoutput>
<cfif x lt days>
<cfset counter = 1>
<cfoutput>
<tr>
</cfoutput>
</cfif>
</cfif>
</cfloop>
<cfif counter is not 8>
<cfset endPad = 8 - counter>
<cfoutput>
<td colspan="#endPad#"> </td>
</tr>
</cfoutput>
</cfif>
<cfoutput>
</table>
</cfoutput>
<cfoutput>
<!---<input name="date" value="#DateFormat(yourDate, "mmmm, d, yyyy")#" />--->
</cfoutput>
</form>
Comment