How can I create a pop-up calendar (or call any other form) to allow users to insert data into a particular field? I have a calendar that opens up but it is a different form that is doing the processing. Is it possible to have one action page but different formattings based on the action chosen?
I am not sure what your goal is, but to try and answer some of your questions: 1. For calendars, you might take a look at either cfcalendar or cfinput type="datefield". Assuming you are using cf8+ http://livedocs.adobe.com/coldfusion/8/Tags_c_02.html 2. Yes, a single action page can perform different actions based on a chosen option. All that is needed is some sort of variable (form field, etc..) to tell the action page which option was chosen. <cfif form.selectedOption is "whatever"> do something <cfelse> do something else </cfif> 3. Passing values from one window to another will require javascript. http://www.w3schools.com/htmldom/prop_win_opener.asp
I got some opensource code for a pop-up calendar. However, I cannot seem to get the value to pass to a field that I created, whereas, it would pass the value successfully to a field that came with the source code. the calendar code is below: <cfparam name="url.popyear" default="#datepart("yyyy",now())#"> <cfparam name="url.popmonth" default="#datepart("m",now())#"> <cfset dateob=CreateDate(popyear,popmonth,1)> <cfset lastyear=DateAdd("yyyy",-1,dateob)> <cfset nextyear=DateAdd("yyyy",1,dateob)> <cfset prev_date=DateAdd("m",-1,dateob)> <cfset next_date=DateAdd("m",1,dateob)> <html> <head> <title>Popup Calendar</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style> body, td{ font-size: 7pt; color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;} .textbold { font-size: 10pt; color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-weight : bold;} .cmon{ background-color: #009933;} .cmon a{ text-decoration: none; color: #FFFFFF;} .cmoff{ background-color: #ffffff;} .cmoff a{ text-decoration: none; color: #000000;} </style> <script type="text/javascript"> <!-- function toggleDisplay(theID) { var theElement = document.getElementById(theID); if (theElement.className == 'cmoff'){ theElement.className = 'cmon' } else { theElement.className = 'cmoff' } } //--> </script> </head> <body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"> <div align="center"> <table width="218" bgcolor="#000000" border="0" cellspacing="1" cellpadding="0"> <tr> <td colspan="7" align="center" bgcolor="#FFFFFF"> <cfoutput><a href="poppedup.cfm?popmonth=#Month(lastyear)#&popyear=#Year(lastyear)#">Prev</a><img src="arrow_green_back.gif" width="7" height="10" border="0" alt=""> <span class="textbold">#MonthAsString(Month(DateOb))# #Year(Dateob)#</span> <img src="arrow_green_next.gif" width="7" height="10" border="0" alt=""><a href="poppedup.cfm?popmonth=#Month(nextyear)#&popyear=#Year(nextyear)#">Next</a></cfoutput> </td> </tr> <tr> <td width="30" bgcolor="#ffffff" align="center">Sun</td> <td width="30" bgcolor="#ffffff" align="center">Mon</td> <td width="30" bgcolor="#ffffff" align="center">Tue</td> <td width="30" bgcolor="#ffffff" align="center">Wed</td> <td width="30" bgcolor="#ffffff" align="center">Thu</td> <td width="30" bgcolor="#ffffff" align="center">Fri</td> <td width="30" bgcolor="#ffffff" align="center">Sat</td> </tr> <tr> <cfset FIRSTOFMONTH=CreateDate(Year(DateOb),Month(DateOb),1)> <cfset TOPAD=DayOfWeek(FIRSTOFMONTH) - 1> <cfset PADSTR=RepeatString("<td width=30 height=20 bgcolor=##f5f5f5> </td>",TOPAD)> <cfoutput>#PADSTR#</cfoutput> <cfset DW=TOPAD> <cfloop index="X" from="1" to="#DaysInMonth(DateOb)#"> <cfset retcal = #DateFormat(CreateDate(popyear,popmonth,x), "mm/dd/yyyy")#> <td width="30" height="20" class="cmoff" id="c<cfoutput>#x#</cfoutput>" align="center" valign="middle"> <a href="javascript:window.opener.document.calform.datebox.value='<cfoutput>#retcal#</cfoutput>'; window.close();" onmouseover="javascript:toggleDisplay('c<cfoutput>#x#</cfoutput>')" onmouseout="javascript:toggleDisplay('c<cfoutput>#x#</cfoutput>')"><cfoutput>#x#</cfoutput></a> </td> <cfset DW=DW + 1> <cfif DW EQ 7> </tr> <cfset DW=0> <cfif X LT DaysInMonth(DateOb)><tr></cfif> </cfif> </cfloop> <cfset TOPAD=7 - DW> <cfif TOPAD LT 7> <cfset PADSTR=RepeatString("<td width=30 height=20 bgcolor=##f5f5f5> </td>",TOPAD)> <cfoutput>#PADSTR#</cfoutput> </cfif> </tr> <tr> <td colspan="7" align="center" bgcolor="#FFFFFF"> <cfoutput> <a href="poppedup.cfm?popmonth=#Month(prev_date)#&popyear=#Year(prev_date)#" >Last Month</a> ~ <a href="poppedup.cfm?popmonth=#Month(next_date)#&popyear=#Year(next_date)#" >Next Month</a> </cfoutput> </td> </tr> </table> </div> </body> </html> I thought the portion in red would have been the only part needed to successfully pass the value back to the form. Call the form (by its name) and the text field (by its name)...but the value still isn't being passed. I would have changed the line to read "javascript:window.opener.document.me.criteria.value" (where the form name is "me" and the text box name is "criteria") Any suggestions?
<FORM action="WASASearch_VSearchResult.cfm" method="post" id="me" name="me"> <INPUT type="hidden" name="StartRow" value="1"> <TABLE> <TR> <TD>Keywords:</TD> <TD><INPUT type="text" name="Criteria" size="30"> <a href="javascript:show_calendar('me.Criteria');" onmouseover="window.status='Date Picker';return true;" onmouseout="window.status='';return true;"><img src="cal.gif" width=16 height=16 border=0></a></TD> </TR> <TR> <TD>Max Rows:</TD> <TD><SELECT name="MaxRows"> <OPTION> 10 <OPTION> 25 <OPTION> 100 </SELECT></TD> </TR> <TR> <TD colspan=2><INPUT type="submit" value=" Search "></TD> </TR> </TABLE> </FORM> This is the code from my form; thought this would have made it easier.
opps, sorted out my own issue.....it seems the javascript code that's updating the field on the original form is case senstive....i chaged "criteria" to "Criteria" and it worked perfectly. :-S
^^I know!! Now I have another problem, i'm trying to create a search with the data passed from the Calendar form, but when I submit the search, it does not use the ENTIRE date pasted into the textbox. But if I search by say a digit representation of the month (eg. February = 02) it returns a hit. Any ideas? The name of the file is something like 02_10_2009. But a search for that exactly returns nothing
Either you are passing the wrong value or there is a problem with your query comparison: 1. What is an example of the textbox date: ie 02/15/2009 2. What does your search query look like 3. What is the data type of the column you are searching ? (datetime, varchar, ...etc) and what is a sample value from that column?
^^^Thanks for the response once again cfStarlight, but I got it. The problem was with the fileitself, the meta data was incorrect and the search criteria was not located anywhere within the document's contents.