1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Coldfusion pop up calendar

Discussion in 'Programming' started by balleyne, Feb 5, 2009.

  1. #1
    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?
     
    balleyne, Feb 5, 2009 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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
     
    cfStarlight, Feb 5, 2009 IP
  3. balleyne

    balleyne Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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="">&nbsp;&nbsp;&nbsp;&nbsp;<span class="textbold">#MonthAsString(Month(DateOb))# #Year(Dateob)#</span>&nbsp;&nbsp;&nbsp;&nbsp;<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>&nbsp;</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>&nbsp;</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?
     
    balleyne, Feb 6, 2009 IP
  4. balleyne

    balleyne Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <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.
     
    balleyne, Feb 6, 2009 IP
  5. balleyne

    balleyne Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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
     
    balleyne, Feb 6, 2009 IP
  6. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Glad you figured it out. It is always the little things that trip you up, isn't it?
     
    cfStarlight, Feb 6, 2009 IP
  7. balleyne

    balleyne Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ^^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
     
    balleyne, Feb 9, 2009 IP
  8. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    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?
     
    cfStarlight, Feb 9, 2009 IP
  9. balleyne

    balleyne Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ^^^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.
     
    balleyne, Feb 11, 2009 IP