Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Coldfusion - Form date picker

Posted on 2009-04-30
13
Medium Priority
?
620 Views
Last Modified: 2012-05-06
I am trying to get a coldfusion date popup script to work.  I have changed the names to fit my form and application but I keep getting a "The web site you are accessing has experienced an unexpected error. Please contact the website administrator." error in the popup window.  I have submitted the orginal and my converted files.  The original files will work in your folder with no modifications. Any help is appreciated.

Thanks,
John
popcalendar.txt
poppedup.txt
poppedupVideoOne.txt
VideoCheckout.txt
0
Comment
Question by:JohnMac328
  • 7
  • 6
13 Comments
 
LVL 53

Expert Comment

by:_agx_
ID: 24272628
What version of CF are you using again?  If you are using CF8, it has a built in date picker:



<cfif structKeyExists(form, "selectedDate")>
	<cfoutput>
	You selected:  #form.selectedDate#
	</cfoutput>
</cfif>
 
<cfform action="#CGI.SCRIPT_NAME#" method="post" format="html">
	<cfinput type="datefield" name="selectedDate">
	<input type="submit" value="Test Calendar">
</cfform>

Open in new window

0
 

Author Comment

by:JohnMac328
ID: 24273812
I don't get any errors but the movie is not checking out to the employee.  It did before when I keyed in the date.  I must be missing something


<cfif not IsDefined('SESSION.EmployeeID')>
  <cflocation url="login.cfm">
</cfif>
 
<cfif structKeyExists(FORM, "submit")>
 
<CFSET new_date = #CREATEODBCDATETIME(Out_Date)#>
 
  <cfparam name="form.watched" default="no">
 
  <cfquery name="enterdetails" datasource="#datasource#">
    INSERT INTO Detail (EmployeeID, VideoID, Out_Date)
    VALUES
    (
        <cfqueryparam value="#form.employeeID#" cfsqltype="cf_sql_integer"> ,
        <cfqueryparam value="#form.VideoID#" cfsqltype="cf_sql_integer"> ,
         <cfqueryparam value="#new_date#" cfsqltype="CF_SQL_TIMESTAMP">
 
       
   
    )
   
    </cfquery>
 
</cfif>
 
 
 
 
<cfquery name="getAllEmployees" datasource="#datasource#">
   SELECT  EmployeeID, First_Name, Last_Name, Email
   FROM    Employees
   ORDER BY Last_Name, First_Name
 </cfquery>
 
<cfquery name="getAllFilms" datasource="#datasource#">
  SELECT VideoList.VideoID, VideoList.Video_Name, VideoList.Length, VideoList.Production_Company, Category.Category_Name, VideoList.Tests, VideoList.Availability, Detail.Out_Date
FROM Category INNER JOIN (VideoList INNER JOIN Detail ON VideoList.VideoID = Detail.VideoID) ON Category.Category_ID = VideoList.CategoryID
 </cfquery>
 
 
 
<cfform action="videoCheckout.cfm" method="post" format="html">
        
        <table width="700">
		<tr>
        <td>
      <select name="employeeID">
          <cfoutput query="getAllEmployees">
             <option value="#employeeID#">#Email#</option>
          </cfoutput>
      </select>
    </td>
      <td>
      <select name="VideoID">
          <cfoutput query="getAllFilms">
             <option value="#VideoID#">#Video_Name#</option>
          </cfoutput>
      </select>
      
       
  <td>
      
      <cfinput type="datefield" name="Out_Date">
   
   </td>
        
        
        
        
        
        
        <input type="submit" value="Submit">
</cfform>

Open in new window

0
 
LVL 53

Expert Comment

by:_agx_
ID: 24274076
Make sure the submit button has the name "submit". Otherwise your CFIF code won't fire.

    <input type="submit" name="submit" value="Submit">
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 

Author Comment

by:JohnMac328
ID: 24274109
I caught that and changed it, still runs but does not enter the movie data.  I have the old version and it does when I type in the date.

 
<style>
input{ font-size: 10pt; color: #000000;	font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;}
</style>
 
<cfif not IsDefined('SESSION.EmployeeID')>
  <cflocation url="login.cfm">
</cfif>
 
<cfif structKeyExists(FORM, "submitButton")>
 
<CFSET new_date = #CREATEODBCDATETIME(Out_Date)#>
 
  <cfparam name="form.watched" default="no">
 
  <cfquery name="enterdetails" datasource="#datasource#">
    INSERT INTO Detail (EmployeeID, VideoID, Out_Date)
    VALUES
    (
        <cfqueryparam value="#form.employeeID#" cfsqltype="cf_sql_integer"> ,
        <cfqueryparam value="#form.VideoID#" cfsqltype="cf_sql_integer"> ,
         <cfqueryparam value="#new_date#" cfsqltype="CF_SQL_TIMESTAMP">
 
       
   
    )
   
    </cfquery>
 
</cfif>
 
<!---  <cfquery name="Check_UserRole" datasource="library">
Select role
FROM Users
Where User_id = '#session.User_id#'
</cfquery>--->
 
 
<cfquery name="getAllEmployees" datasource="#datasource#">
   SELECT  EmployeeID, First_Name, Last_Name, Email
   FROM    Employees
   ORDER BY Last_Name, First_Name
 </cfquery>
 
<cfquery name="getAllFilms" datasource="#datasource#">
  SELECT VideoList.VideoID, VideoList.Video_Name, VideoList.Length, VideoList.Production_Company, Category.Category_Name, VideoList.Tests, VideoList.Availability, Detail.Out_Date
FROM Category INNER JOIN (VideoList INNER JOIN Detail ON VideoList.VideoID = Detail.VideoID) ON Category.Category_ID = VideoList.CategoryID
 </cfquery>
 
 
 
<form method="post" style="margin:0px"  action="videoCheckoutbk.cfm">
  <table width="700">
		<tr>
        <td>
      <select name="employeeID">
          <cfoutput query="getAllEmployees">
             <option value="#employeeID#">#Email#</option>
          </cfoutput>
      </select>
    </td>
      <td>
      <select name="VideoID">
          <cfoutput query="getAllFilms">
             <option value="#VideoID#">#Video_Name#</option>
          </cfoutput>
      </select>
      
      <td><input type="text" name="Out_Date" size="30"></td>
			
			 
			
      
 
 
  
 
    
 <!---<cfif check_user.Role('Admin')>
 code to show for Admin users only
</cfif> 
 <td><cfif session.role eq 1>
 
     <input type="radio" name="watched" value="yes"> Yes
      <input type="radio" name="watched" value="no" checked> No
      </cfif>
       </td>
 
  <td>
 
  <input type="radio" name="checked_out" value="yes"> Yes
      <input type="radio" name="checked_out" value="no" checked> No
 </td>--->
     
      <input type="submit" name="submitButton">
</tr>
	</table>
</form>
 
 
 
 
 
 
 

Open in new window

0
 
LVL 53

Expert Comment

by:_agx_
ID: 24274172
Is it throwing an error or just not inserting anything?  As long as the cfif is firing, I would expect either an error or for the record to be inserted.

Try add some debugging code to the query.  What results do you get?

<cfif structKeyExists(FORM, "submit")>
    <CFSET new_date = #CREATEODBCDATETIME(Out_Date)#>
    <cfparam name="form.watched" default="no">
     <cfdump var="#FORM#" label="Form Values">

    <cfquery name="enterdetails" datasource="#datasource#" result="myResults">
         ... same sql here ...
    </cfquery>
     <cfdump var="#myResults#" label="Query Results">
</cfif>
0
 

Author Comment

by:JohnMac328
ID: 24274235
Ok, first I get no error and nothing gets inserted with the new date function.  Second I get nothing with the new cfdump, I'm getting confused
<CFSET new_date = #CREATEODBCDATETIME(Out_Date)#>
 
   <cfdump var="#FORM#" label="Form Values">
 
  <cfquery name="enterdetails" datasource="#datasource#" result="myResults">
    INSERT INTO Detail (EmployeeID, VideoID, Out_Date)
    VALUES
    (
        <cfqueryparam value="#form.employeeID#" cfsqltype="cf_sql_integer"> ,
        <cfqueryparam value="#form.VideoID#" cfsqltype="cf_sql_integer"> ,
         <cfqueryparam value="#new_date#" cfsqltype="CF_SQL_TIMESTAMP">
 
       
   
    )
   
    </cfquery>
<cfdump var="#myResults#" label="Query Results">
</cfif>

Open in new window

0
 
LVL 53

Expert Comment

by:_agx_
ID: 24274268
Oops. I didn't notice your button was named "submitButton".  I corrected that.  Also, it should at least display a message if the submit button was not found (or the first time the page is loaded).  Try it again now.  

>  I get nothing with the new cfdump,

If you are not seeing anything at all .. it is most likely that the CFIF is not firing.  So I added an cfelse clause. So at least you will see _some_ message if it is not firing.


<cfif structKeyExists(FORM, "submitButton")>
    <CFSET new_date = #CREATEODBCDATETIME(Out_Date)#>
    <cfparam name="form.watched" default="no">
     <cfdump var="#FORM#" label="Form Values">
 
<cfquery name="enterdetails" datasource="#datasource#" result="myResults">
    INSERT INTO Detail (EmployeeID, VideoID, Out_Date)
    VALUES
    (
        <cfqueryparam value="#form.employeeID#" cfsqltype="cf_sql_integer"> ,
        <cfqueryparam value="#form.VideoID#" cfsqltype="cf_sql_integer"> ,
         <cfqueryparam value="#new_date#" cfsqltype="CF_SQL_TIMESTAMP">
 
       
   
    )
     <cfdump var="#myResults#" label="Query Results">
<cfelse>
  form.submitButton does not exist
</cfif>

Open in new window

0
 

Author Comment

by:JohnMac328
ID: 24274337
Ok, I get the  form.submitButton does not exist  message on the screen.  Why does it not see the submit button?  

Here is the form


<cfform action="videoCheckout.cfm" method="post" format="html">
        
        <table width="700">
		<tr>
        <td>
      <select name="employeeID">
          <cfoutput query="getAllEmployees">
             <option value="#employeeID#">#Email#</option>
          </cfoutput>
      </select>
    </td>
      <td>
      <select name="VideoID">
          <cfoutput query="getAllFilms">
             <option value="#VideoID#">#Video_Name#</option>
          </cfoutput>
      </select>
      
       
  <td>
      
      <cfinput type="datefield" name="Out_Date">
   
   </td>
        
        
        
        
        
        
        <input type="submitButton" value="Submit">
</cfform>

Open in new window

0
 
LVL 53

Expert Comment

by:_agx_
ID: 24274385
> <input type="submitButton" value="Submit">

You took out the name again ;-)   That happens when testing new code.  

Just make sure the button name is the same as what you are using in the CFIF statement:

     <!--- both values must be the same ---->
      <cfif structKeyExists(FORM, "submitButton")>  
       .....
       <input type="submitButton" name="submitButton"  value="Submit">
0
 

Author Comment

by:JohnMac328
ID: 24274443
I still get the  form.submitButton does not exist  message on the screen.  The only difference is that I am using the cold fusion form, does it have a special name for submit buttons?

 
<style>
input{ font-size: 10pt; color: #000000;	font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;}
</style>
 
<cfif not IsDefined('SESSION.EmployeeID')>
  <cflocation url="login.cfm">
</cfif>
 
<cfif structKeyExists(FORM, "submitButton")>
 
<CFSET new_date = #CREATEODBCDATETIME(Out_Date)#>
 
   <cfdump var="#FORM#" label="Form Values">
 
  <cfquery name="enterdetails" datasource="#datasource#" result="myResults">
    INSERT INTO Detail (EmployeeID, VideoID, Out_Date)
    VALUES
    (
        <cfqueryparam value="#form.employeeID#" cfsqltype="cf_sql_integer"> ,
        <cfqueryparam value="#form.VideoID#" cfsqltype="cf_sql_integer"> ,
         <cfqueryparam value="#new_date#" cfsqltype="CF_SQL_TIMESTAMP">
 
       
   
    )
   
    </cfquery>
<cfdump var="#myResults#" label="Query Results">
 
<cfelse>
  form.submitButton does not exist
</cfif>
 
 
 
 
<cfquery name="getAllEmployees" datasource="#datasource#">
   SELECT  EmployeeID, First_Name, Last_Name, Email
   FROM    Employees
   ORDER BY Last_Name, First_Name
 </cfquery>
 
<cfquery name="getAllFilms" datasource="#datasource#">
  SELECT VideoList.VideoID, VideoList.Video_Name, VideoList.Length, VideoList.Production_Company, Category.Category_Name, VideoList.Tests, VideoList.Availability, Detail.Out_Date
FROM Category INNER JOIN (VideoList INNER JOIN Detail ON VideoList.VideoID = Detail.VideoID) ON Category.Category_ID = VideoList.CategoryID
 </cfquery>
 
 
 
<cfform action="videoCheckout.cfm" method="post" format="html">
        
        <table width="700">
		<tr>
        <td>
      <select name="employeeID">
          <cfoutput query="getAllEmployees">
             <option value="#employeeID#">#Email#</option>
          </cfoutput>
      </select>
    </td>
      <td>
      <select name="VideoID">
          <cfoutput query="getAllFilms">
             <option value="#VideoID#">#Video_Name#</option>
          </cfoutput>
      </select>
      
       
  <td>
      
      <cfinput type="datefield" name="Out_Date">
   
   </td>
        
        
        
        
        
        
         <input type="submitButton" name="submitButton"  value="Submit">
</cfform>

Open in new window

0
 
LVL 53

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 24274469
> does it have a special name for submit buttons?

No.  Don't be confused by the fact that you will see that message the first time the page loads.  That is because the form wasn't submitted yet.  Change the submit button to this:

       <input type="submit" name="submitButton" value="Submit">

It works for me:
0
 

Author Closing Comment

by:JohnMac328
ID: 31576547
That time it took, thanks again agx.  I'll be back :)
0
 
LVL 53

Expert Comment

by:_agx_
ID: 24274579
You are welcome.  See you around :)
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question