How to accomplish the following behavior

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

How to accomplish the following behavior

Post by yacahuma »

I am not sure how to do this.

I have a page where I am using facebox(http://chriswanstrath.com/facebox/) Basically it allows you to display a popup using div and it loads the content from an external page. In my case the popup has a form that when submitted is supposed to call a page that generates a pdf. I want to be able to display the popup, submit the form, make the popup disappear, and get the file downloaded without my original page to change. In other words I want the whole popup-submit thing to behave just like if I clicked on an href.


Right now if I put a target="_blank" I get a new page. And if I live it like this, it will replace my current page iwth a white page, and the files is downloaded.

I am sure there is some javascript code that I need.

The only thing in the main page is the link

Code: Select all

<a href="external_page.php?id_post=42" rel="facebox">Generate Document</a>
This is my external_page.php that is displayed inside the popup

Code: Select all

<?php
    if (isset($_GET['submitbtn']))
    {
        $url = url built from several options
        header("Location: $url");    //THIS PAGE IS THE ONE THAT GENERATES THE PDF
    }

?>    
    <body>
        <form action="_wnd_docgen.php" method="get">
            Document: <select><options...></select>
            <input type="submit" id="submitbtn" name="submitbtn" value="Go"/>
        </form>
    </body>
Post Reply