4

I have a page with this basic process:

  • Click checkboxes next to forms you want to download
  • Click submit
  • CFWindow pops up to collect some basic info
  • Click submit to download forms while staying in the window that was opened by CFWindow

When you click the submit button inside the CFWindow , it brings you back to the parent page. I want the form submission to stay inside the CFWindow. I saw this post: Refresh cfwindow content. However, the refreshOnShow = "true" does not work. Every time I hit submit, it goes back to the parent window.

Here is the Parent page:

<cfform name="myform">
   <cfinput type="hidden" name="OrgID" value="#getit.orgID#">
   <table width="95%" border="0" cellspacing="5" cellpadding="0" align="center">
      <tr>
         <td width="50%" valign="top" class="coretextforBR">
            <cfinput type="checkbox" name="GetThese" value="#form_ID#">
            <a class="corelinkforBR">#Forms_Name#</a>
            <br /><br />
            #Forms_Description#
            <br /><br />
         </td>
      </tr>
      <tr>
         <td width="50%" valign="top" class="coretextforBR">
            <cfinput type="checkbox" name="GetThese" value="#form_ID#">
            <a class="corelinkforBR">#Forms_Name#</a>
            <br /><br />
            #Forms_Description#
            <br /><br />
         </td>
      </tr>
      <tr>
         <td width="50%" valign="top" class="coretextforBR">
            <cfinput type="checkbox" name="GetThese" value="#form_ID#">
            <a class="corelinkforBR">#Forms_Name#</a>
            <br /><br />
            #Forms_Description#
            <br /><br />
         </td>
      </tr>
      <tr>
         <td colspan="2">
            <input type="submit"value="Get It" onclick="javascript:ColdFusion.Window.show('mywindow1')">
         </td>
      </tr>
   </table>
</cfform>   

     <cfwindow x="250" y="250" width="400" height="400" 
        name="mywindow1" title="Almost ready to download" initshow="false" draggable="false" resizable="false" 
        refreshOnShow="true" source="submitform.cfm?GetThese={myform:GetThese.value}&OrgID={myform:OrgID}&action=information" 
        bodystyle="background-color: white;" headerStyle="background-color: ###getcss.color#; font-family: #getcss.font#; color: ###getcss.fontcolor#;" /> 

Here is the source (submit.cfm) for the CFWwindow:

<cfparam name="attributes.action" default="information">
<cfoutput>
   <html>
   <head>
      <style type="text/css">
      </style>
   </head>
   <body>
      This window will collect information to begin download
      <br>
      <!--- action for downloading --->
      <cfif attributes.action eq "download">
         <cfloop info and stuff left out>
            <a href="./log_download.cfm?filename=#Forms_File#&OrgID=#UrlEncodedFormat( '#Forms_OrgID#' )#" class="corelinkforBR">#Forms_Name#</a><br />
         </cfloop>
      <!--- what you see when page initially loads --->
      <cfelse>
            <form action="submitform.cfm?action=download" method="post">
               <input type="hidden" name="GetThese" value="#attributes.GetThese#">
               <input type="hidden" name="OrgID" value="#attributes.OrgID#">
               <table width="95%" border="0" align="center">
                  <tr>
                     <td class="coretextforBR">First:</td>
                     <td><input type="text" name="CollectedInfo_First"></td>
                  </tr>
                  <tr>
                     <td class="coretextforBR">Last:</td>
                     <td><input type="text" name="CollectedInfo_Last"></td>
                  </tr>
                  <tr>
                     <td class="coretextforBR">Phone:</td>
                     <td><input type="text" name="CollectedInfo_Phone"></td>
                  </tr>
                  <tr>
                     <td class="coretextforBR">Email:</td>
                     <td><input type="text" name="CollectedInfo_Email"></td>
                  </tr>
                  <tr>
                     <td class="coretextforBR">Best way <br> to contact:</td>
                     <td><input type="text" name="CollectedInfo_BestWay"></td>
                  </tr>
                  <tr>
                     <td colspan="2"><input type="submit" value="Download" class="button one"></td>
                  </tr>
               </table>
            </form>
      </cfif>
</cfoutput>
</body>
</html>

I have no idea what I am doing wrong. I couldn't find a definite answer to my problem either other than the refreshOnShow. Should I rethink and do a ajax submit?

Community
  • 1
  • 1
Adam
  • 51
  • 6
  • Why not simply put the other form fields on the same page as the checkboxes? – Dan Bracuk Mar 21 '16 at 16:47
  • they dont want them there. :-( – Adam Mar 21 '16 at 16:54
  • 2
    What if you give the form inside submit.cfm a `target` of the window opened with cfwindow? I guess `mywindow1` in your example. *OR* Define the `cfwindow` in the submit.cfm file instead of with the other form. – Miguel-F Mar 21 '16 at 20:13
  • 1
    If memory serves, the cfwindow script must use a ``, rather than a regular html `
    ` to post to the same "window". Having said that, the CF ajax controls are .. a bit clunky and have a number number of quirks. Have you considered using an external library, like jquery? There are numerous plugins, but a [basic modal window](http://jqueryui.com/dialog/#modal-form) is pretty simple to implement.
    – Leigh Mar 21 '16 at 20:16
  • Liegh The cfform actually worked, it stays in the same window. But I get an error "Error retrieving markup for element window1_body: Not Found" EDIT - found solution on google. – Adam Mar 23 '16 at 13:47
  • Miguel-F. With the Modal window, will that go through even with someone who has an ad-block/pop up blocker? I know the CF window does. – Adam Mar 23 '16 at 13:50

1 Answers1

0

Using <cfform> instead of normal <form> worked as Liegh suggested.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Adam
  • 51
  • 6