Step 1.
Add the following code via a "insert php snippet" to the page where you want to include a link (or button if you choose) to open a new popup window.
echo "
<!-- Codes by Quackit.com -->
<script type=\"text/javascript\">
// Popup window code
function newPopup(url) {
popupWindow = window.open(
url,'popUpWindow','height=400,width=530,left=20,top=20,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}
</script>
<a href=\"JavaScript:newPopup('http://localhost/your_other_application_form_add.php';);\">Add New Comment</a>";
Step 2.
In the page that gets opened inside the popup window, you add this code to Javascript OnLoad
$("#submit2").bind("click", {page: this}, function(e){
var page = e.data.page;
page.on('beforeSave', function(formObj, fieldControlsArr, pageObj){
formObj.baseParams['submit2'] = 'Save and back to list';
}, page, {single: true});
page.on('afterSave', function(respObj, formObj, fieldControlsArr, pageObj){
delete formObj.baseParams['submit2'];
}, page, {single: true});
page.saveHn(e);
});
Step 3.
Add a new button (or simply replace existing save button) on that popup form to "save and close" such as:
<INPUT class=button id=submit2 type=button value="Save And Close" name=submit2>
Step 4.
Now, in the same popup form go to the event "After Record Added" (or if editing find the event counterpart) and add this:
if ($_REQUEST["submit2"]=="Save And Close")
{
echo "<script type=\"text/javascript\">window.close();</script>";
exit();
}
That is it. Now your popup will automatically save and close.
Special Note: I want to acknowledge that steps 2 through 4 were adapted (99% of it) from Jane's entry here: http://www.asprunner.com/forums/topic/10748-adding-an-additional-button-to-the-edit-page/
Cheers,