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. -
<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>
-
3 2131 acoder 16,027
Recognized Expert Moderator MVP
Put "form.month_val " in quotes in isDefined(). You could also use cfparam to give form variables default values. There's some code that could be improved, but we can deal with that later.
Param's turned out to be the answer. Here is the correctly working calendar: -
<div id="calHolder">
-
<p>
-
<cfoutput>
-
<div align="center"><h3>#DateFormat(now(), "mmmm, d, yyyy")#</h3></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 - Select Year - Click "Go"</div>
-
<p align="center">
-
-
<p align="center">
-
<cfoutput>
-
Month: <select name="month_val">
-
<option></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>
-
<!---<input name="month_val" value="#month(now())#" />--->
-
</cfoutput>
-
<cfoutput>
-
Year: <select name="year_val">
-
<option></option>
-
<option>2008</option>
-
<option>2009</option>
-
<option>2010</option>
-
<option>2011</option>
-
<option>2012</option>
-
<option>2013</option>
-
<option>2014</option>
-
<option>2015</option>
-
</select>
-
<!---<input name="year_val" value="#year(now())#" />--->
-
</cfoutput>
-
<input type="submit" name="Go" value="GO" />
-
<cfoutput>
-
</p>
-
</form>
-
<!--- +++++++++++++++++++++++++++ --->
-
<!---
-
THIS WAS THE PROBLEM SECTION
-
THE PARAM'S FIXED THE PROBLEM
-
--->
-
<!--- +++++++++++++++++++++++++++ --->
-
<cfparam name="month_val" type="integer" default="#DatePart('m', Now())#">
-
<cfparam name="year_val" type="integer" default="#DatePart('yyyy', Now())#">
-
<cfset monthTitle = #month_val#>
-
<cfset yearTitle = #year_val#>
-
<!---Display the selected month and year--->
-
<p>
-
<div align="center" id="calSelectedYM">
-
<cfif monthTitle EQ 1>
-
January
-
<cfelseif monthTitle EQ 2>
-
February
-
<cfelseif monthTitle EQ 3>
-
March
-
<cfelseif monthTitle EQ 4>
-
April
-
<cfelseif monthTitle EQ 5>
-
May
-
<cfelseif monthTitle EQ 6>
-
June
-
<cfelseif monthTitle EQ 7>
-
July
-
<cfelseif monthTitle EQ 8>
-
August
-
<cfelseif monthTitle EQ 9>
-
September
-
<cfelseif monthTitle EQ 10>
-
October
-
<cfelseif monthTitle EQ 11>
-
November
-
<cfelseif monthTitle EQ 12>
-
December
-
</cfif>
-
<cfif yearTitle EQ 2008>
-
2008
-
<cfelseif yearTitle EQ 2009>
-
2009
-
<cfelseif yearTitle EQ 2010>
-
2010
-
<cfelseif yearTitle EQ 2011>
-
2011
-
<cfelseif yearTitle EQ 2012>
-
2012
-
<cfelseif yearTitle EQ 2013>
-
2013
-
<cfelseif yearTitle EQ 2014>
-
2014
-
<cfelseif yearTitle EQ 2015>
-
2015
-
</cfif>
-
</div><!--/calSelectedYM-->
-
</p>
-
<!---/END PROBLEM SECTION--->
-
<!---/Display the selected month and year--->
-
<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 width="14%"></cfoutput>
-
<cfelse>
-
<cfoutput><td width="14%"></cfoutput>
-
</cfif>
-
-
<cfset yourDate = createDate(#year_val#, #month_val#, #x#)>
-
-
<cfquery name="Events" datasource="ds_pattern">
-
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">#descr#<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>
-
</form>
-
</div><!--/calHolder-->
-
acoder 16,027
Recognized Expert Moderator MVP
Pleased to see that it's working, though the displaying of the month and year code looks terribly inefficient. Rather than those if statements, just display the value using cfoutput. For the month, set the option values to the name of the month.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: inigo.villalba |
last post by:
Hi,
I hope someone can point out my error because I'm starting to lose my
hair over this. It's probably a very straigh forward error but after
only 4 hours sleep it's doing my head in. It's to do with global
variables in Firefox 1.
The following code works no problems and generates a whole bunch of
numbers
<script type="text/javascript">
|
by: Stimp |
last post by:
preferably one that when clicked can update three date dropdowns (day,
month, year) like
http://www.visitdublin.com/carhire/avis.asp
Don't mind paying for the file... anyone seen something like this?
--
"I hear ma train a comin'
.... hear freedom comin"
|
by: Jim |
last post by:
What is the JavaScript function that fires when a date is selected on the
calendar control?
Jim
|
by: Hutty |
last post by:
I'm trying create a calendar control that updates an access database with
events. I have some code I managed to piece together. First error I'm
running into is the Mycommand.ExecuteNonQuery(). I get an error on this line
as it looks for the query. Here's the first piece of the code where I'm able
to get display calendar and the input boxes. Just trying to write back to
database. Thanks in advance.
Public Sub Page_Load(ByVal Sender...
|
by: GV |
last post by:
Hi all,
New to developing in VS 2005 ASP 2.0
Trying to have a easy pop calender for a button on a web page.
I keep getting a error message in IE6 that says:
Line 69
Char 3
Error: 'this.container' is null or not an object
| |
by: JM |
last post by:
I'm studying for webdeveloper. The trainer only comments when it doesn't
work, but I am also interested in comments on programs or pieces of code
that work : can it work better, faster, shorter, ...
I made an object to show a monthly calendar using PHP, OOP and DOM (and
MySQL). If possible I would like some more experienced programmers to
review/comment my code (logic, design, code, names, ...). I hope to
learn from it.
For more...
|
by: thorpk |
last post by:
I posted this problem earlier in the month and some one decided it was
better to change the subject and ask a completely different question.
I am therefore reposting. I am hoping some one can assist with this.
Thanks in advance.
I have an access database that i have added a pop up calendar to, the
Table information for the Date Reported field is
Date/Time
format short date,
input mask is 00/00/0000.
|
by: magmike |
last post by:
Can I do anything with the calendar buttons? I want to display a
number on the buttons.
I'm using the calendar control on a form that sets a call back date
and time. The user can click on the calendar if they wish to set the
date in the date field. It also serves the purpose of using a
calendar. Also on that form, I have a subform that shows a query which
shows the count of call backs set for each date. I would like to be
able to...
|
by: swethak |
last post by:
Hi,
I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the events when click on that date that perticular event displyed in a text box.But my requirement is to when click on that date that related event displyed in same td row not the text box. and also i add the events to that calendar.plz advice how to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |