Skip to main content
Inspiring
November 22, 2007
Question

Open popup on form submission in a cfdiv

  • November 22, 2007
  • 5 replies
  • 820 views
Hi,

I have a form in a cfdiv that onsubmit opens a popup window (not a cfwindow) so that I can print the results of the form using a print() function. The problem I have is that the form submission stays within the cfdiv. The popup opens but doesn't seem to capture the form. The results of the form appear in the cfdiv.

Is there any way to target a popup window from within a cfdiv so that I can send the form to the popup?

I have also tried using cfwindow to open with the form results but when I run a javascript: print() I get the word 'false' displayed in my print preview. All other content is missing?

Any ideas?

Cheers,

Dave
    This topic has been closed for replies.

    5 replies

    Inspiring
    November 22, 2007
    I got around the problem by removing my cflayout tabs and then it was easy to turn off the various containers not needed by the print function. So I call the print() function from within the cfdiv and use a print stylesheet to hide all the extra stuff that is not required.

    Thanks for the help though.
    Inspiring
    November 22, 2007
    If that is in the case then, you should try the,

    window.action='action_page';
    window.submit();

    statements.

    HTH
    Inspiring
    November 22, 2007
    Sorry, I'm being dense. Could you expand upon your last reply? Where would these statements fit in my javascript? Is this a limitation of using cfdiv.
    Inspiring
    November 22, 2007
    Hi,

    I tried something like this,

    Inspiring
    November 22, 2007
    Hi Dave,

    I wrongly typed 'window,open' - It should be window.open, Can you replace that thing and make another try?
    Inspiring
    November 22, 2007
    Oops, I should have spotted that!

    The popup opens as before but the results of the form (printlabel.cfm) still loads into the cfdiv. Do I need to specify the target in a different way so that the ColdFusion js knows where I am trying to send the form?

    Cheers,

    Dave
    Inspiring
    November 22, 2007
    Hi,

    What happens when you rewrite your statement,

    open ('', windowName, features);

    as

    newWindow=window,open ('', windowName, features);
    newWindow.focus();



    Inspiring
    November 22, 2007
    I get no popup at all!
    Inspiring
    November 22, 2007
    Hi,

    Can you please post your code here?
    Inspiring
    November 22, 2007
    index.cfm sets up a layout:

    <cflayout type="tab" name="mainTab" style="width:750px;">
    <!--- Each layoutarea is one tab. --->
    <cflayoutarea title="Labels" name="tab1" style="padding: 0 0 15px 15px;">
    <cfform>
    <table border="0" cellpadding="5" cellspacing="0">
    <tr>
    <td>Customer Surname.:</td>
    <td> </td>
    </tr>
    <tr>
    <td><cfinput type="text" name="lastname" autosuggest="cfc:orders.getCustomerByLastname({cfautosuggestvalue})"></td>
    <td><input type="submit" name="filterbtn" value="Filter" onclick="ColdFusion.Grid.refresh('orders', false); return false;"></td>
    </tr>
    </table>
    <cfgrid name="orders"
    format="html"
    pagesize="10"
    striperows="yes"
    bind="cfc:patient.getPatients({cfgridpage},
    {cfgridpagesize},
    {cfgridsortcolumn},
    {cfgridsortdirection},getSearchString())"
    bindonload="false">
    <cfgridcolumn name="patientid" display="false" />
    <cfgridcolumn name="orderid" header="Order ID" width="100" />
    <cfgridcolumn name="orderdate" header="Order Date" width="150"/>
    <cfgridcolumn name="patientname" header="Patient" width="450"/>
    </cfgrid>
    </cfform>
    <cfdiv id="labelform" bind="url:labelform.cfm?patientid={orders.patientid}&orderid={orders.orderid}" style="margin: 15px 0 0 0; width: 100%;" />
    </cflayoutarea>
    </cflayout>

    labelform.cfm then has a form which I want to submit into a popup (printlabel.cfm)
    labelform.cfm:
    <script type="text/javascript">
    function openTarget (form, features, windowName) {
    if (!windowName)
    windowName = 'formTarget' + (new Date().getTime());
    form.target = windowName;
    open ('', windowName, features);
    }
    </script>
    <cfform action="printlabel.cfm" name="labelfrm" method="post" onsubmit="openTarget(this,'width=300,height=300,resizable=1,scrollbars=1'); return true;" target="newpopup">snip</cfform>

    printlabel.cfm:

    <cfoutput>
    <table border="0" cellpadding="0" cellspacing="0" style="width: 55mm; height: 22mm; padding: 3mm;">
    <tr><td><strong>#qProducts.fullname#</strong> (#form.quantity#)</td></tr>
    <tr><td>#form.details#</td></tr>
    <tr><td><strong>#qPatient.patientname#</strong> (#LSDateFormat(Now(), "dd/mm/yy")#)</td></tr>
    </table>
    </cfoutput>

    The popup opens but the contents of printlabel.cfm appear in the cfdiv portion of the page instead of the popup.

    Cheers,

    Dave