Solved

CF - CFwindow problem

Posted on 2010-09-02
24
530 Views
Last Modified: 2012-05-10
I am trying to get a pop up to work. The pop up works until I try to get the form inside to run correctly.  When I have the form action set to the page with the pop up is where it bombs.  Any help is appreciated
<cfajaximport tags="cfwindow">



<cfif isDefined("FORM.Deleting")>

	<cfquery datasource="#datasource#">

		UPDATE Files

		SET IntranetFile='#FORM.IntranetFile#',

			Title='#FORM.Title#',

			Dept='#Form.Dept#',

			Display='2'

where ID=#FORM.ID#

	</cfquery>

    <cfelseif isDefined("FORM.Editing")>

	<cfquery datasource="#datasource#">

		UPDATE Files

		SET IntranetFile='#FORM.IntranetFile#',

			Title='#FORM.Title#',

			Dept='#Form.Dept#',

			Display='1'

where ID=#FORM.ID#

	</cfquery>

</cfif>



<cfquery name="getFiles" datasource="#datasource#">

	SELECT *

	FROM Files order by IntranetFile

</cfquery>



<cfwindow initShow="false" title="Welcome to <CFWINDOW>"

         center="true" resizable="true"

         draggable="false" name="mywin">

         

 <cfoutput query="getFiles"> 

     

  <cfform method="post" style="margin:0px" action="Test.cfm">

	<cfinput type="hidden" name="ID" value="#ID#">

   <cfinput type="text" name="IntranetFile"

			value="#IntranetFile#" size="50" class="#Display#">

   <cfinput type="text" name="Title"

			value="#Title#" size="50" class="#Display#">

   <cfinput type="text" name="Dept"

			value="#Dept#" size="5" class="#Display#">         

 <cfselect name="Display">

 

      <option value='1' <cfif Display EQ 1>SELECTED</cfif> >Displayed</option>

                <option value='2' <cfif Display EQ 2>SELECTED</cfif> >Removed</option>

  </cfselect>

  <cfinput type="submit" name="editing"

			value="RESTORE" style="font-size:xx-small"> 

   

         

		<cfinput type="submit" name="deleting"

			value="REMOVE" style="font-size:xx-small">

	

		

</cfform>

</cfoutput>

  

  

  <form>

  <input type="button" value="Close Me!" onClick="ColdFusion.Window.hide('mywin')">

  </form>

  

  </cfwindow>

  

  <p>

  <a href="javaScript:ColdFusion.Window.show('mywin')">Show Window</a><br />

  

  </p>

Open in new window

0
Comment
Question by:JohnMac328
  • 12
  • 10
  • 2
24 Comments
 

Author Comment

by:JohnMac328
ID: 33591319
Is there a way to get the form to run without the action calling a page?
0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 33594112
Hi please try the following code, I tested it. It is working. it is submitting the form to the test.cfm file.
<!--- <cfajaximport tags="cfwindow"> --->



<cfif isDefined("FORM.Deleting")>

	<cfquery datasource="#datasource#">

		UPDATE Files

		SET IntranetFile='#FORM.IntranetFile#',

			Title='#FORM.Title#',

			Dept='#Form.Dept#',

			Display='2'

where ID=#FORM.ID#

	</cfquery>

    <cfelseif isDefined("FORM.Editing")>

	<cfquery datasource="#datasource#">

		UPDATE Files

		SET IntranetFile='#FORM.IntranetFile#',

			Title='#FORM.Title#',

			Dept='#Form.Dept#',

			Display='1'

where ID=#FORM.ID#

	</cfquery>

</cfif>



<cfquery name="getFiles" datasource="#datasource#">

	SELECT *

	FROM Files order by IntranetFile

</cfquery>



<html>

    <head>

    </head>

    <body>

<cfwindow initShow="false" title="Welcome to <CFWINDOW>"

         center="true" resizable="true"

         draggable="false" name="mywin">

         

 <cfoutput query="getFiles"> 

     

  <cfform method="post" style="margin:0px" action="Test.cfm">

	<cfinput type="hidden" name="ID" value="#ID#">

   <cfinput type="text" name="IntranetFile"

			value="#IntranetFile#" size="50" class="#Display#">

   <cfinput type="text" name="Title"

			value="#Title#" size="50" class="#Display#">

   <cfinput type="text" name="Dept"

			value="#Dept#" size="5" class="#Display#">         

 <cfselect name="Display">

 

      <option value='1' <cfif Display EQ 1>SELECTED</cfif> >Displayed</option>

                <option value='2' <cfif Display EQ 2>SELECTED</cfif> >Removed</option>

  </cfselect>

  <cfinput type="submit" name="editing"

			value="RESTORE" style="font-size:xx-small"> 

   

         

		<cfinput type="submit" name="deleting"

			value="REMOVE" style="font-size:xx-small">

	

		

</cfform>

</cfoutput>

  

  

  <form>

  <input type="button" value="Close Me!" onClick="ColdFusion.Window.hide('mywin')">

  </form>

  

  </cfwindow>

  

  <p>

  <a href="#" onclick="javaScript:ColdFusion.Window.show('mywin')">Show Window</a><br />

  

  </p>

</body>

</html>

Open in new window

0
 
LVL 9

Expert Comment

by:Shaun McNicholas
ID: 33595142
The cf window tag embeds the form and it's accompanying action within the page you are currently running, it's doing html requests via ajax and pulling the requested page on demand almost like a cfinclude. So if you don't define a location for the action then the action returns the form variable to the page that called it. So the above suggestion should work if your action pushes the variables to another page where you define methods or actions to be performed on those changes.
0
 

Author Comment

by:JohnMac328
ID: 33596110
Maestropsm

If I change the form action from  Test.cfm to Edit.cfm, would I just have the queries on the edit.cfm page?
0
 
LVL 9

Expert Comment

by:Shaun McNicholas
ID: 33596270
Yes you do all your queries for modifying the database on the action page where your form is submitted and then refresh the original page.
You can also leave the action blank and put the queries for updates on the original page where the cfwindow is loaded - or do an if statement and if the variables for updating the form exist - then cfinclude the queries page.

So if you have a page page1.cfm that has a cfwindow on it that calls cfwindow.cfm
Then in the window you have a submit button <cfinput type="submit" name="UpdateVariables" value="UPDATE">
Then at the top of page1.cfm you would put
<cfif IsDefined("UpdateVariables")>
<cfinclude template="queriesUpdatePage.cfm">
</cfif>

That way if the window is submitted it calls the update queries and then continues to refresh the original page1.cfm
0
 

Author Comment

by:JohnMac328
ID: 33596479
Ok, getting confused.  Here is the test.cfm and the edit.cfm   I had to rename them to .txt to upload. Test.cfm has the link and brings up the popup with the form and the fields displayed to be updated.  The action on that form goes to edit.cfm but it still does not work so I am missing something.
Test.txt
0
 

Author Comment

by:JohnMac328
ID: 33596486
and here is edit.cfm
Edit.txt
0
 

Author Comment

by:JohnMac328
ID: 33596853
Actually this is what I started with but the popup had none of the edit.cfm contents in the box, it was blank.  If this would work it would take care of all the issues.
<td><cfinput type="button" name="x" value="Create Window" 

        onClick="ColdFusion.Window.create('Window1', 'This is a CF window',

        'http://localhost//edit.cfm',

        {x:100,y:100,height:500,width:700,modal:false,closable:true,

        draggable:true,resizable:true,center:true,initshow:true,

        minheight:200,minwidth:200 })"></td>

Open in new window

0
 
LVL 9

Expert Comment

by:Shaun McNicholas
ID: 33597200
Move everything except the following code from the test page:

Then move all your queries to the edit page.
I would rename the Restore button value to UPDATE or MODIFY - since you're doing more than just restoring the file.

You're missing the cfform tag in the cfajaxinclude, and the cfwindow source="edit.cfm", I put the modal tag in there so you can see how the window grays out the background to make your eye focus on the window so it's clear where you should be focussing your attention.

And they must have changed the cfwindow behaviors in version 9 - in version 8 what I said earlier was true but apparently in version 9 CF now handles everything within the window like you would think it would.

Also you don't need FORM - before each variable when called from a form. You can just reference them directly.
The variables you reference in the queries should be unified - you have some caps and some not.
And last - I would put labels in front of your inputs on the form so people know what they are editing.

<cfajaximport tags="cfform,cfwindow"> 



<html>

    <head>

    </head>

    <body>



<cfwindow initShow="false" title="Modify File" center="true" resizable="true" refreshOnShow="true" modal="false" source="edit.cfm" draggable="false" name="mywin"></cfwindow>



<form>

<input type="button" value="Close Me!" onClick="ColdFusion.Window.hide('mywin')">

</form>

<p>

<a href="#" onClick="javaScript:ColdFusion.Window.show('mywin')">Show Window</a><br />

</p>

</body>

</html>

Open in new window

0
 
LVL 9

Expert Comment

by:Shaun McNicholas
ID: 33597213
BTW - you don't need the close button on the calling page since windows come with a closing [x] in the top right corner.
0
 

Author Comment

by:JohnMac328
ID: 33597292
Ok, I did make the changes.  I still get just a blank screen in the popup.  As for the buttons I am only showing a file on the screen based on its role, it is either showing or not.  That is why I have display and restore.  In this stripped down version I don't have labels but I do in the final version.  

What I posted a couple of messages back is what I tried to get working in the first place.  It seems so straight forward, any reason why this does not work?


<td><cfinput type="button" name="x" value="Create Window" 

        onClick="ColdFusion.Window.create('Window1', 'This is a CF window',

        'http://localhost//edit.cfm',

        {x:100,y:100,height:500,width:700,modal:false,closable:true,

        draggable:true,resizable:true,center:true,initshow:true,

        minheight:200,minwidth:200 })"></td>

Open in new window

0
 
LVL 9

Expert Comment

by:Shaun McNicholas
ID: 33597577
Can you copy the code for both pages up here
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:JohnMac328
ID: 33597597
Up where?
0
 
LVL 9

Expert Comment

by:Shaun McNicholas
ID: 33597713
in the code option here in EE
0
 

Author Comment

by:JohnMac328
ID: 33597746
I have the code for ID 33597200 and my original edit.cfm.  The pop up is blank
0
 
LVL 9

Accepted Solution

by:
Shaun McNicholas earned 500 total points
ID: 33598184
Well I'll just let you decode this:
Here are the files I have working fine in my environment.
One thing I noticed - when using cfwindow - if there are errors in the code for your window like you are trying to reference a variable that isn't defined - for some reason nothing displays and you just get a blank page - so you probably have an error - I had to look at the source of the blank page in order to see what the error was. It's listed there but you have to go look for what the error message is. It will say something like - liine 58 of edit.cfm Display is not defined.

Anyway here is my code which is working fine.
test.cfm is the first 21 lines - followed by edit.cfm separated by a note entry.
<!--- test.cfm is the first 21 lines of code --->

<cfajaximport tags="cfform,cfwindow"> 

<html>
    <head>
    </head>
    <body>

<cfwindow initShow="false" title="Modify File" center="true" resizable="true" refreshOnShow="true" modal="false" source="edit.cfm" draggable="false" name="mywin"></cfwindow>
  
  <form>
  <input type="button" value="Close Me!" onClick="ColdFusion.Window.hide('mywin')">
  </form>

  
  <p>
  <a href="#" onClick="javaScript:ColdFusion.Window.show('mywin')">Show Window</a><br />
  
  </p>
</body>
</html>

<!--- edit.cfm starts here --->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File Manager</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<cfajaximport tags="cfwindow">
<cfif isDefined("deleting")>
	<cfquery datasource="donovan_stats">
		UPDATE fileDB
		SET fileName='#IntranetFile#',
			fileTitle='#Title#',
			fileCategory='#Dept#',
			displayTag='2'
        where fileKey=#ID#
	</cfquery>
    <cfelseif isDefined("editing")>
	<cfquery datasource="donovan_stats">
		UPDATE fileDB
		SET fileName='#IntranetFile#',
			fileTitle='#Title#',
			fileCategory='#Dept#',
			displayTag='1'
        where fileKey=#ID#
	</cfquery>
</cfif>
<cfquery name="getFiles" datasource="donovan_stats">
	SELECT *
	FROM fileDB order by FileName
</cfquery>


<body>
 <cfoutput query="getFiles"> 
     
  <cfform method="post" style="margin:0px" action="Edit.cfm">
	<cfinput type="hidden" name="ID" value="#fileKey#">
   <cfinput type="text" name="IntranetFile"
			value="#fileName#" size="50">
   <cfinput type="text" name="Title"
			value="#fileTitle#" size="50">
   <cfinput type="text" name="Dept"
			value="#fileCategory#" size="5">         
 <cfselect name="Display">
 
      <option value='1' <cfif displayTag IS 1>SELECTED</cfif> >Displayed</option>
                <option value='2' <cfif displayTag IS 2>SELECTED</cfif> >Removed</option>
  </cfselect>
  <cfinput type="submit" name="editing"
			value="RESTORE" style="font-size:xx-small"> 
   
         
		<cfinput type="submit" name="deleting"
			value="REMOVE" style="font-size:xx-small">
	
		
</cfform>
</cfoutput>
</body>
</html>

Open in new window

0
 

Author Comment

by:JohnMac328
ID: 33598266
I did a view source and it did not display an error, when the blank popup comes up, how did you see the error?
0
 

Author Comment

by:JohnMac328
ID: 33598662
Ok, I added the

<cfajaximport tags="cfform,cfwindow">

and now this works by itself

<cfinput type="button" name="x" value="Edit Files"
        onClick="ColdFusion.Window.create('Window1', 'This is a CF window',
        'http://localhost/Intranet/edit.cfm',
        {x:100,y:100,height:500,width:700,modal:false,closable:true,
        draggable:true,resizable:true,center:true,initshow:true,
        minheight:200,minwidth:200 })">

Now the strange this is the "Restore" button works but the "Remove" does not inside the window.  I have the same form outside the pop up window and both functions work.  Any idea why one would change a value in the table but the other will not change the same value?  Sorry about this being such a frustrating question, I appreciate your patience.
0
 
LVL 9

Expert Comment

by:Shaun McNicholas
ID: 33598906
Show me both queries as you currently have them on the page.
0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 33598945
You can have only one submit button in a form. try subbmiting form from javascript function in your code for one button and let anoher button be submit buton.
0
 
LVL 9

Expert Comment

by:Shaun McNicholas
ID: 33599092
@ansudhindra - that's actually not true - you just have to give each submit button a different name and then in your if statements you determine which button was pressed - which is how John has his buttons setup. I use this method all the time.
0
 

Author Comment

by:JohnMac328
ID: 33599496
Here they are, I tried to find some difference.  Maybe another set of eyes
<cfif isDefined("FORM.Deleting")>

	<cfquery datasource="#datasource#">

		UPDATE Files

		SET IntranetFile='#FORM.IntranetFile#',

			Title='#FORM.Title#',

			Dept='#Form.Dept#',

			Display='2'

where ID=#FORM.ID#

	</cfquery>

    <cfelseif isDefined("FORM.Editing")>

	<cfquery datasource="#datasource#">

		UPDATE Files

		SET IntranetFile='#FORM.IntranetFile#',

			Title='#FORM.Title#',

			Dept='#Form.Dept#',

			Display='1'

where ID=#FORM.ID#

	</cfquery>

</cfif>

Open in new window

0
 
LVL 9

Expert Comment

by:Shaun McNicholas
ID: 33599680
What happens if you change all the form variables to their names without Form in front of them and set the Deleting to deleting and Editing to editing. Maybe your web server is case sensitive.

And is your #datasource# defined?
At the top of the page are you setting datasource to the name of your CF DSN(data source name)?

<cfif isDefined("deleting")>

	<cfquery datasource="#datasource#">

		UPDATE Files

		SET IntranetFile='#IntranetFile#',

			Title='#Title#',

			Dept='#Dept#',

			Display='2'

        WHERE ID=#ID#

	</cfquery>

    <cfelseif isDefined("editing")>

	<cfquery datasource="#datasource#">

		UPDATE Files

		SET IntranetFile='#IntranetFile#',

			Title='#Title#',

			Dept='#Dept#',

			Display='1'

        WHERE ID=#ID#

	</cfquery>

</cfif>

Open in new window

0
 

Author Comment

by:JohnMac328
ID: 33599748
I tried everything you said except removing Form.  I tried that and still the Restore button works and the Remove button does not.  Outside the pop up window they both work with no problem.  I guess I will just not use a pop up but it bugs me because if one button works they both should.  I may try taking out the <cfelseif and making two separate cfif and see what happens
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now