Processing a Coldfusion cfform within a CFWindow.

Posted on 2011-10-31
Last Modified: 2012-05-12
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?
Question by:Garbonzo_Horowitz
    LVL 39

    Accepted Solution


    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...


    Author Comment

    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?

    LVL 39

    Expert Comment


    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"


    Author Comment

    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".
    LVL 51

    Assisted Solution

    > <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.


    Author Closing Comment

    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.
    LVL 51

    Expert Comment

    > 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.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
    Introduction HyperText Transfer Protocol ( 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…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    729 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

    19 Experts available now in Live!

    Get 1:1 Help Now