Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Getting Started / August 2006



Tip: Looking for answers? Try searching our database.

Need help with cookie in form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
chieffan - 30 Aug 2006 17:09 GMT
I have a form that produces a schedule of task for a user based on their start
date.  I want to set a cookie based on the date they select from a pop up
calendar that populates a form field called date1. In the else section where I
set the value to date1, if I do #form.date1# it days undefined and form.date1
will actually put that text in the box.  Thanks.

<input type="Text" name="date1" value="
 <cfif IsDefined("cookie.startdate")>
 <CFOUTPUT>#cookie.startdate#</cfoutput>
  <cfelse>
 <!--- <CFOUTPUT>#DateFormat(Now())#</cfoutput>--->
  <cfcookie name="startdate" value="#date1#" expires="never">
  </cfif>
">  <img src="images/cal.jpg" width="22" height="18"
onclick='javascript:ShowCal("document.task.date1.value")'/>
<input type="hidden" name="date2" value="<CFOUTPUT>#DateFormat(Now())#</
CFOUTPUT>"><input type="hidden" value="w" name="type" />
<input type="Submit" value="Create Plan" >
<input type="RESET">
</p>
</form>
chieffan - 30 Aug 2006 17:37 GMT
they are the same.  This is the entire page.  Maybe perhaps adding after
<cfif IsDefined("form.date1") and IsDefined("form.date2")> ?

<P><script src="DateChooser.js" language="javascript"></script>
<TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>
<TBODY>
<TR>
<TD style="BACKGROUND-COLOR: #cccc99" height=26><IMG
src="/firststage/images/fscm.jpg" align=center></TD></TR></TBODY></TABLE></P>
<P>[B]Create a Plan[/B]</P>

<cfif IsDefined("form.value")>
   <cfset value = form.value>
</cfif>
<cfif IsDefined("form.type")>
   <cfset type = form.type>
 
</cfif>
 <cfparam name="type" default="w">
 
<cfif IsDefined("form.date1") and IsDefined("form.date2")>
<!---<cfset "#hireDate#" =form.date1>--->

   <cfif IsDate(form.date1) and IsDate(form.date2)>
   
   
     
      <cfif DateCompare("#form.date1#","#form.date2#") is not 0>
      <p>This plan is based on a start date of
<cfoutput>#DateFormat(form.date1, "mmm d, yyyy")#</cfoutput>.  If you follow
the plan below, you will complete the First Stage Credit Manager program in
four weeks.  Print this plan and check off items as you complete
them.<!---<cfoutput>#Abs(DateDiff("d", form.date2,
form.date1))#</cfoutput>---></p><p>
<!---
      <cfswitch expression = "#form.type#">
         <cfcase value="yyyy">years</cfcase>
         <cfcase value="q">quarters</cfcase>
         <cfcase value="m">months</cfcase>
         <cfcase value="y">days</cfcase>  
         <cfcase value="d">days</cfcase>  
         <cfcase value="w">weekdays</cfcase>  
         <cfcase value="ww">weeks</cfcase>  
         <cfcase value="h">hours</cfcase>  
         <cfcase value="n">minutes</cfcase>  
         <cfcase value="s">seconds</cfcase>      
         <cfdefaultcase>years</cfdefaultcase>
      </cfswitch>.---></p>
      <cfquery name="courses" datasource="aid0510">
  SELECT CourseName,DayFromStart FROM DailyTasks
--WHERE DayFromStart>#Abs(DateDiff("d", form.date2, form.date1))#
 ORDER BY DayFromStart;
    </cfquery>

 <!--- <cfloop query="courses" >--->

  <cfoutput query="courses" group="DayFromStart" >
  <cfset newDate= DateAdd('w','#DayFromStart#','#form.date1#')>
  <cfset dateHeader= DateFormat(newDate, "dddd, mmm d, yyyy")>
  [B]<cfif newDate eq DateFormat(now(), "mmm d, yyyy")>
         <font color="green">
    <cfelseif newDate lt now()>
             <font color="red">
    <cfelseif newDate gt now()>
    <font color="black">
    <cfelse>
    <font color="black">
    </cfif>
    #dateHeader#</font>[/B]<br />
  <ul style="list-style-image:url(images/checkbox.jpg); list-style:square">  
    <cfoutput>[LI]#CourseName#</li></cfoutput>
  [/BULLET]
  <br />
  </cfoutput>
 <!--- </cfloop>--->
      <cfelse>
      <p>This plan is based on a start date of
<cfoutput>#DateFormat(form.date1, "mmm d, yyyy")#</cfoutput>.  If you follow
the plan below, you will complete the First Stage Credit Manager program in
four weeks.  Print this plan and check off items as you complete
them.<!---<cfoutput>#Abs(DateDiff("d", form.date2,
form.date1))#</cfoutput>---></p><p>
     <cfquery name="coursesall" datasource="aid0510">
  SELECT * FROM DailyTasks
 
    </cfquery>
      <cfoutput query="coursesall" group="DayFromStart" >
  <cfset newDate= DateAdd('w','#DayFromStart#','#form.date1#')>
  <cfset dateHeader= DateFormat(newDate, "dddd, mmm d, yyyy")>
  <cfif newDate eq DateFormat(now(), "mmm d, yyyy")>
         <font color="green">
    <cfelse>
    <font color="black">
    </cfif>
  [B]#dateHeader#[/B]</font>[/B]<br />
  <ul style="list-style-image:url(images/checkbox.jpg); list-style:square">  
    <cfoutput>[LI]#CourseName#</li></cfoutput>
  [/BULLET]
  </cfoutput>
    <!---   <cfquery name="coursesall" datasource="aid0510">
  SELECT * FROM DailyTasks
 
    </cfquery>

  <cfloop query="courses" >
   
  <cfoutput >#CourseName#,
#DayFromStart#,#DateAdd('d','#DayFromStart#','#form.date1#')#</cfoutput><br />
  </cfloop>
 --->
      </cfif>
   
   <cfelse>
   <p>Please enter two valid date/time values, formatted like this:
   <cfoutput>#DateFormat(Now())#</cfoutput>  
   </cfif>  

</cfif>
<div id="hiredateform">
<form name="task" action="" method="post">

<p>To create your personal plan to complete the First Stage Credit Manager
program, select you start date and click "Create Plan."</p>
<p>
 
  <input type="Text" name="date1" value="
 <cfif IsDefined("cookie.startdate")>
 <CFOUTPUT>#cookie.startdate#</cfoutput>
  <cfelse>
 <!--- <CFOUTPUT>#DateFormat(Now())#</cfoutput>--->
  <cfcookie name="startdate" value="#date1#" expires="never">
  </cfif>
">  <img src="images/cal.jpg" width="22" height="18"
onclick='javascript:ShowCal("document.task.date1.value")'/>
<input type="hidden" name="date2" value="<CFOUTPUT>#DateFormat(Now())#</
CFOUTPUT>"><input type="hidden" value="w" name="type" />
<input type="Submit" value="Create Plan" >
<input type="RESET">
</p>
</form>

</div>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.