473,625 Members | 2,600 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calendar Woes With Form Variables

2 New Member
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.

Expand|Select|Wrap|Line Numbers
  1. <cfoutput>
  2. <div align="center"><h2>#DateFormat(now(), "mmmm, d, yyyy")#</h2></div>
  3. </cfoutput>
  4. </p>
  5.  
  6. <form name="cal_select" method="get" action="#CGI.script_name#">   
  7.    <div align="center">To view the events of a particular month:<br />Select Month Number - Enter Year - Click "Go"</div>
  8.    <p align="center">
  9.  
  10. <p align="center">
  11. <input type="submit" name="Go" value="GO" />
  12. <cfoutput>
  13. <select name="month_val">
  14.     <option>#month(now())#</option>
  15.     <option>1</option>
  16.     <option>2</option>
  17.     <option>3</option>
  18.     <option>4</option>
  19.     <option>5</option>
  20.     <option>6</option>
  21.     <option>7</option>
  22.     <option>8</option>
  23.     <option>9</option>
  24.     <option>10</option>
  25.     <option>11</option>
  26.     <option>12</option>
  27. </select>
  28. </cfoutput>
  29. <cfoutput>
  30. <input name="year_val" value="#year(now())#" />
  31. </cfoutput>
  32. <cfoutput>
  33.  
  34. </cfoutput>
  35. <cfoutput>
  36. </p></form>
  37.  
  38. <!---Display the selected month--THIS IS WERE THE ERROR IS OCCURING--->
  39. <p>
  40. <div align="center">
  41. <cfif isDefined(form.month_val)>
  42.     <cfif form.month_val EQ 1>
  43.     January
  44.     <cfelseif form.month_val EQ 2>
  45.     February
  46.     <cfelseif form.month_val EQ 3>
  47.     March
  48.     <cfelseif form.month_val EQ 4>
  49.     April
  50.     <cfelseif form.month_val EQ 5>
  51.     May
  52.     <cfelseif form.month_val EQ 6>
  53.     June
  54.     <cfelseif form.month_val EQ 7>
  55.     July
  56.     <cfelseif form.month_val EQ 8>
  57.     August
  58.     <cfelseif form.month_val EQ 9>
  59.     September
  60.     <cfelseif form.month_val EQ 10>
  61.     October
  62.     <cfelseif form.month_val EQ 11>
  63.     November
  64.     <cfelseif form.month_val EQ 12>
  65.     December
  66.     </cfif>
  67. </cfif>
  68. </div>
  69. </p>
  70. <!---/Display the selected month -- END ERROR SECTION--->
  71.  
  72.  
  73. <form name="caltest1" method="post">
  74.  
  75. <table border="1" width="100%">
  76. <tr>
  77. <cfloop index="x" from="1" to="7">
  78. <th><span class="style2 style4">#dayOfWeekAsString(x)#</span></th>
  79. </cfloop>
  80. </tr>
  81. </cfoutput>
  82.  
  83. <cfparam name="year_val" type="integer" default="#DatePart('yyyy', Now())#">
  84. <cfparam name="month_val" type="integer" default="#DatePart('m', Now())#">
  85.  
  86. <cfset firstOfTheMonth = CreateDate(#year_val#, #month_val#, 1)>
  87. <cfset dow = dayofWeek(firstOfTheMonth)>
  88. <cfset pad = dow - 1>
  89.  
  90. <cfoutput>
  91. <tr>
  92. </cfoutput>
  93.  
  94. <cfif pad gt 0>
  95. <cfoutput><td colspan="#pad#">&nbsp;</td></cfoutput>
  96. </cfif>
  97.  
  98. <cfset days = daysInMonth(firstOfTheMonth)>
  99. <cfset counter = pad + 1>
  100.  
  101. <cfloop index="x" from="1" to="#days#">
  102. <cfif x is day(now())>
  103. <cfoutput><td bgcolor="yellow" width="14%"></cfoutput>
  104. <cfelse>
  105. <cfoutput><td width="14%"></cfoutput>
  106. </cfif>
  107.  
  108. <cfset yourDate = createDate(#year_val#, #month_val#, #x#)>
  109.  
  110. <cfquery name="Events" datasource="ds_eventsCalendar">
  111. SELECT *
  112. FROM tbl_events
  113. WHERE start_date=#CreateODBCDate(yourDate)#
  114. </cfquery>
  115.  
  116. <cfoutput>
  117. <div align="center">
  118. <strong>#DateFormat(yourDate, "d")#</strong>
  119. </cfoutput>
  120. <p>
  121. <cfoutput query="Events">
  122. <div align="center">#desc#<br /></div>
  123. <p>
  124. </cfoutput>
  125. </td>
  126. </div>
  127.  
  128. <cfset counter = counter + 1>
  129. <cfif counter is 8>
  130. <cfoutput></tr>
  131.  
  132.  
  133. </cfoutput>
  134. <cfif x lt days>
  135. <cfset counter = 1>
  136. <cfoutput>
  137. <tr>
  138. </cfoutput>
  139. </cfif>
  140. </cfif>
  141. </cfloop>
  142.  
  143. <cfif counter is not 8>
  144. <cfset endPad = 8 - counter>
  145. <cfoutput>
  146. <td colspan="#endPad#">&nbsp;</td>
  147.  
  148. </tr>
  149. </cfoutput>
  150. </cfif>
  151.  
  152. <cfoutput>
  153. </table>
  154. </cfoutput>
  155. <cfoutput>
  156. <!---<input name="date" value="#DateFormat(yourDate, "mmmm, d, yyyy")#" />--->
  157. </cfoutput>
  158. </form>
  159.  
Sep 23 '08 #1
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.
Sep 24 '08 #2
ClanKeithROoF
2 New Member
Param's turned out to be the answer. Here is the correctly working calendar:

Expand|Select|Wrap|Line Numbers
  1. <div id="calHolder">
  2. <p>
  3. <cfoutput>
  4. <div align="center"><h3>#DateFormat(now(), "mmmm, d, yyyy")#</h3></div>
  5. </cfoutput>
  6. </p>
  7. <form name="cal_select" method="get" action="#CGI.script_name#">   
  8. <div align="center">To view the events of a particular month:<br />Select Month Number - Select Year - Click "Go"</div>
  9. <p align="center">
  10.  
  11. <p align="center">
  12. <cfoutput>
  13. Month: <select name="month_val">
  14.     <option></option>
  15.     <option>1</option>
  16.     <option>2</option>
  17.     <option>3</option>
  18.     <option>4</option>
  19.     <option>5</option>
  20.     <option>6</option>
  21.     <option>7</option>
  22.     <option>8</option>
  23.     <option>9</option>
  24.     <option>10</option>
  25.     <option>11</option>
  26.     <option>12</option>
  27. </select>
  28. <!---<input name="month_val" value="#month(now())#" />--->
  29. </cfoutput>
  30. <cfoutput>
  31. Year: <select name="year_val">
  32.     <option></option>
  33.     <option>2008</option>
  34.     <option>2009</option>
  35.     <option>2010</option>
  36.     <option>2011</option>
  37.     <option>2012</option>
  38.     <option>2013</option>
  39.     <option>2014</option>
  40.     <option>2015</option>
  41. </select>
  42. <!---<input name="year_val" value="#year(now())#" />--->
  43. </cfoutput>
  44.  <input type="submit" name="Go" value="GO" />
  45. <cfoutput>
  46. </p>
  47. </form>
  48. <!--- +++++++++++++++++++++++++++ --->
  49. <!---
  50. THIS WAS THE PROBLEM SECTION 
  51. THE PARAM'S FIXED THE PROBLEM
  52. --->
  53. <!--- +++++++++++++++++++++++++++ --->
  54. <cfparam name="month_val" type="integer" default="#DatePart('m', Now())#">
  55. <cfparam name="year_val" type="integer" default="#DatePart('yyyy', Now())#">
  56. <cfset monthTitle = #month_val#>
  57. <cfset yearTitle = #year_val#>
  58. <!---Display the selected month and year--->
  59. <p>
  60. <div align="center" id="calSelectedYM">
  61.     <cfif monthTitle EQ 1>
  62.     January
  63.     <cfelseif monthTitle EQ 2>
  64.     February
  65.     <cfelseif monthTitle EQ 3>
  66.     March
  67.     <cfelseif monthTitle EQ 4>
  68.     April
  69.     <cfelseif monthTitle EQ 5>
  70.     May
  71.     <cfelseif monthTitle EQ 6>
  72.     June
  73.     <cfelseif monthTitle EQ 7>
  74.     July
  75.     <cfelseif monthTitle EQ 8>
  76.     August
  77.     <cfelseif monthTitle EQ 9>
  78.     September
  79.     <cfelseif monthTitle EQ 10>
  80.     October
  81.     <cfelseif monthTitle EQ 11>
  82.     November
  83.     <cfelseif monthTitle EQ 12>
  84.     December
  85.     </cfif>
  86.     <cfif yearTitle EQ 2008>
  87.      2008
  88.     <cfelseif yearTitle EQ 2009>
  89.      2009
  90.     <cfelseif yearTitle EQ 2010>
  91.      2010
  92.     <cfelseif yearTitle EQ 2011>
  93.      2011
  94.     <cfelseif yearTitle EQ 2012>
  95.      2012
  96.     <cfelseif yearTitle EQ 2013>
  97.      2013
  98.     <cfelseif yearTitle EQ 2014>
  99.      2014
  100.     <cfelseif yearTitle EQ 2015>
  101.      2015
  102.     </cfif>
  103. </div><!--/calSelectedYM-->
  104. </p>
  105. <!---/END PROBLEM SECTION--->
  106. <!---/Display the selected month and year--->
  107. <form name="caltest1" method="post">
  108. <table border="1" width="100%">
  109. <tr>
  110. <cfloop index="x" from="1" to="7">
  111. <th><span class="style2 style4">#dayOfWeekAsString(x)#</span></th>
  112. </cfloop>
  113. </tr>
  114. </cfoutput>
  115.  
  116. <cfparam name="year_val" type="integer" default="#DatePart('yyyy', Now())#">
  117. <cfparam name="month_val" type="integer" default="#DatePart('m', Now())#">
  118.  
  119. <cfset firstOfTheMonth = CreateDate(#year_val#, #month_val#, 1)>
  120. <cfset dow = dayofWeek(firstOfTheMonth)>
  121. <cfset pad = dow - 1>
  122.  
  123. <cfoutput>
  124. <tr>
  125. </cfoutput>
  126.  
  127. <cfif pad gt 0>
  128. <cfoutput><td colspan="#pad#">&nbsp;</td></cfoutput>
  129. </cfif>
  130.  
  131. <cfset days = daysInMonth(firstOfTheMonth)>
  132. <cfset counter = pad + 1>
  133.  
  134. <cfloop index="x" from="1" to="#days#">
  135. <cfif x is day(now())>
  136. <cfoutput><td width="14%"></cfoutput>
  137. <cfelse>
  138. <cfoutput><td width="14%"></cfoutput>
  139. </cfif>
  140.  
  141. <cfset yourDate = createDate(#year_val#, #month_val#, #x#)>
  142.  
  143. <cfquery name="Events" datasource="ds_pattern">
  144. SELECT *
  145. FROM tbl_events
  146. WHERE start_date=#CreateODBCDate(yourDate)#
  147. </cfquery>
  148.  
  149. <cfoutput>
  150. <div align="center">
  151. <strong>#DateFormat(yourDate, "d")#</strong>
  152. </cfoutput>
  153. <p>
  154. <cfoutput query="Events">
  155. <div align="center">#descr#<br /></div>
  156. <p>
  157. </cfoutput>
  158. </td>
  159. </div>
  160.  
  161. <cfset counter = counter + 1>
  162. <cfif counter is 8>
  163. <cfoutput></tr>
  164.  
  165. </cfoutput>
  166. <cfif x lt days>
  167. <cfset counter = 1>
  168. <cfoutput>
  169. <tr>
  170. </cfoutput>
  171. </cfif>
  172. </cfif>
  173. </cfloop>
  174.  
  175. <cfif counter is not 8>
  176. <cfset endPad = 8 - counter>
  177. <cfoutput>
  178. <td colspan="#endPad#">&nbsp;</td>
  179.  
  180. </tr>
  181. </cfoutput>
  182. </cfif>
  183.  
  184. <cfoutput>
  185. </table>
  186. </cfoutput>
  187. </form>
  188. </div><!--/calHolder-->
  189.  
Sep 24 '08 #3
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.
Sep 25 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

22
5461
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">
19
2092
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"
0
873
by: Jim | last post by:
What is the JavaScript function that fires when a date is selected on the calendar control? Jim
3
2760
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...
0
2005
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
1
1400
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...
3
2722
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.
14
2241
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...
1
4895
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...
0
8251
marktang
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...
0
8182
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,...
0
8688
Oralloy
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...
0
8635
jinu1996
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...
0
8494
tracyyun
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...
0
7178
agi2029
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...
1
6115
isladogs
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...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.