Processing a Coldfusion cfform within a CFWindow.

There seems to be some redirection issue when processing a cfform within a cfwindow.

I have a list product page where I execute cfwindow code to delete a product. The code looks like this:

onclick="ColdFusion.Window.create('popupWindow#ProductID#','Alert!','/folderA/folderB/WindowSource.cfm?ProductID=#URLEncodedFormat(ToString(Productid))#',{x:100,y:100,height:300,width:400,modal:true,closable:false,draggable:false,resizable:false,center:true,_cf_refreshOnShow:true})" />  

Then the WindowContent page contains:

<cfif NOT isDefined("FORM.btnDelete")>

	<!--- code to decrypt URL.ProductID --->
        Are you sure you would like to delete: <br>

	<cfform name="deleteForm" mehtod="post">
		<cfinput type="hidden" name="hiddenProduct" value="#URL.ProductID"#>
		<cfinput type="button" name="btnDelete" value="Yes" onClick="this.form.submit();">
	<input type="button" onClick="javascript:Coldfusion.Window.hide('popupWindow#URL.RecordID#');" name="btnNo" value="No">


	<!--- // cfquery to delete specific record // --->

					closeTheWindow = function() {


		<cfset AjaxOnLoad("closeTheWindow")> 


Open in new window


Whenever I press the 'Yes' button the form submits and the browser opens up the WindowContent page.
It does not close the window and it does not delete the record.

Can someone offer an example of the correct way to use cfform withing a cfwindow?
Who is Participating?

Not sure what all the code you're using is for, but cfform posts asynchronously within the cfwindow.

This will post within the window...

<cfform action="...thepath..">
    <input type="submit" name="doDelete" value=" Delete ">

Process the page and close the window...

Garbonzo_HorowitzAuthor Commented:
Thank you for your reply gdemaria.

I tried that with #cgi.script_name# in the action but it still opend up window content page.

Is that how you would do it?


Take the contents of your cfwindow and place it in a separate file...


Inside that file... place your action at the top...

<cfif isDefined("form.doDelete")>
    ... process the delete..
       close the window

In your example, you are using this path...


So in your example, this would also be the action for the cfform

And place the form below...

Your form's action path should be a relative path to this file "DeletePopUp.cfm"

Upgrade your Question Security!

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

Garbonzo_HorowitzAuthor Commented:
Are you saying I should include the new DeletePopUp.cfm in the WindowSource.cfm file or are you asking me to not use the WindowSource.cfm file?

I don't see the difference if you mean for me to include the DeletePopUp.cfm page.

Can you please elaborate just a little bit more on what you want me to separate out?

Perhaps it would be better if I explained a little bit further myself.

Please check out the files I included. "Explaination.txt" and "DeletePopUp.cfm".
> <cfinput type="button" name="btnDelete" value="Yes" onClick="this.form.submit();">

Use a regular "submit" button. I think this.form.submit() bypasses some of the CF ajax stuff and that may be why it's not working as you expect.

Garbonzo_HorowitzAuthor Commented:
The forms action page had to point to the parent page and not the windowcontent page. Also I changed the this.form.submit to a regular submit.

Thank you for your help.
> The forms action page had to point to the parent page and not the windowcontent page

Technically it doesn't have to. You can post the cfwindow form to itself. But since you probably want to refresh the parent list after deleting the record, posting to parent makes more sense.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.