Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
DeliK #1
Problem saving data and closing popup windows
I seem to be missing something, but don't know what. :confused;
I have a screen from which a user can click on a button that brings up a popup
window. The user can then enter information for a new contact in that window.
What is supposed to happen then is that the user clicks on save, the data is
saved to the database and the information is returned to the calling screen and
the popup window is closed.
What is happening is the data is being saved (the page posts to itself and
runs SQL to save toa database), but I can't seem to close the form and return
the data to the calling form. I thought I could use javascript to do it, but
the javascript code doesn't seem to execute after the data is saved. If I
reset the page, the javascript does run.
I know how to have the javascript run and return information to a calling page
if I don't have data to save first. Can anyone help me figure out what I am
missing? Just a high level explanation of the process of getting the popup to
close and return after saving data would probably suffice. Examples are always
appreciated, of course. :)
DeliK Guest
-
closing popup window moves mouse to top of page
Hi, I'm a beginning using Dreamweaver 8. I have a site with multiple thumbnails on a page. Each thumb is linked to a popup window with the enlarged... -
Closing Popup window
I have 3 pages. The first has a button which opens a popup window. The secons (popupwindow) has a butoon which leeds to the third page. When I... -
Not prompted for saving changes when closing dirty form
"P" <plavallee@rcn.com> wrote in message news:PZAQa.20158$BM.5816308@newssrv26.news.prodigy.com... The acSavePrompt is referring to saving design... -
Movie Closing?? & Windows Closing??
> Can anyone tell me why when I create a projector, it closes after about 10th of a second, it simply opens and closes stright away. Do you have a... -
Saving serialized data to database problem
Hi! Anyone who knows about saving serialized data to database, coz I have a problem with that. If I just serialize my session data and then... -
MikerRoo #2
Re: Problem saving data and closing popup windows
Your approach may not work on all browsers -- since there is too much happening
between the user's click and the attempt to close the window (browsers
increasingly block that sort of thing).
You may need to immediately close the popup and post, the form, to the calling
window.
That said, here's an outline of an approach that might work:
Write a javascript variable, say "bFormSubmissionComplete =false" to the HTML
header of the popup.
The form processing code would set this flag to true (Assumes that you do all
logic first and then write HTML last).
At the end of the body tag, javascript would fire that closes the window if
the flag is true.
Alternatively, if you have good layered-architecture code:
On a virgin popup, write just the needed form HTML.
On a successful form submission, just write the window-closing javascript.
Cheers,
-- MikeR
MikerRoo Guest
-
The ScareCrow #3
Re: Problem saving data and closing popup windows
Process
Open opoup
User input
save data
read saved data
assign data that has been read to js vars
assign js vars to "main" window
close popup.
The attached code should give you a starting point.
Ken
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<cfif isdefined("form.submit")>
<cftry>
<cftransaction>
<cfquery name="rs_save" datasource="dsn">
Insert Into myTable(column1)
Values('#form.text1#')
</cfquery>
<cfquery name="rs_id" datasource="dsn">
Select Max(rec_Id) As MaxId
From myTable
</cfquery>
<cfquery name="rs_read" datasource="dsn">
Select column1
From myTable
Where rec_Id = #rs_id.MaxId#
</cfquery>
<script language="JavaScript">
<cfoutput query="rs_read">
var myText = "#rs_read.column1#";
</cfoutput>
opener.myText.value = myText;
self.close;
</script>
</cftransaction>
<cfcatch type="Any">
Sorry error....
</cfcatch>
</cftry>
</cfif>
<cfoutput>
<form action="#SCRIPT_NAME#" method="post" name="form1" id="form1">
<input type="text" name="text1">
<input type="submit" name="submit" value="Save Data">
</form>
</cfoutput>
</body>
</html>
The ScareCrow Guest



Reply With Quote

