Problem saving data and closing popup windows

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139