Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Form Action

  1. #1
    New Coder
    Join Date
    May 2005
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Form Action

    I have a form that appears in a popupwindow. I found a javascript code that allows me to return to the opener window onClick and it closes the popwindow. The problem is I tried to implement the code into my Form Action and I can't get it to work.

    This is the original code:

    onClick="return targetopener(this, true)

    This is what I'm trying to do:

    <form action='return targetopener(<%Response.Write("checkboxtrial2.asp?Model=" & Recordset("model") & "")%>, true)' name="formOptions" method="post">

    thanks.SalJB

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Isn't this what you wanted?
    Code:
    function closeMe(){
      if (opener && !opener.closed){
         opener.focus();
      }
      window.close();
    }
    ...
    <input type="button" value="Close" onclick="closeMe()" />

  • #3
    New Coder
    Join Date
    May 2005
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    solved

    Thanks ,I solved it with this.

    Code:
     --parent page:
     <script language="javascript">
       if (!window.opener)
      {
       window.name = "parentWindow";
      }
      else
      {
       window.name = "childWindow";
      }
     </script>

    Code:
     --child page:
     <form action="checkboxtrial2.asp?Model=<%=Recordset("model")%>" name="formOptions" method="post" target="parentWindow" onsubmit="window.close();">

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Do the popup window need to be submitted to checkboxtrial2.asp? Your solution will close the popup before it is submitted to that asp page.

  • #5
    New Coder
    Join Date
    May 2005
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    update

    Yes, it does. The window will close and the info wouldn't get passed so I had to adjust and put the below code:

    onsubmit="setTimeout('window.close();', 1000);"

    instead of

    onsubmit="window.close();"

    Sorry, I forgot to post the update for others to view.

    SalJB

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Quote Originally Posted by saljb
    Yes, it does. The window will close and the info wouldn't get passed so I had to adjust and put the below code:

    onsubmit="setTimeout('window.close();', 1000);"
    That is not reliable especially for users with slow internet connection.
    The most reliable way is to close the window while in checkboxtrial2.asp page.

    checkboxtrial2.asp:
    Code:
    <%
    'process request here
    %>
    <html>
    <head>
    <title>Processing done</title>
    <script type="text/javascript">
    window.onload = function(){
       if (opener && !opener.closed){
         opener.focus();
      }
      window.close();
    }
    </script>
    </head>
    <body>
    <div>Processing done.</div>
    </body>
    </html>
    You can even delay the closing a bit to make the status message more readable.
    Code:
    <%
    'process request here
    %>
    <html>
    <head>
    <title>Processing done</title>
    <script type="text/javascript">
    window.onload = function(){
      setTimeout("closeMe()", 1000);
    }
    
    function closeMe(){
       if (opener && !opener.closed){
         opener.focus();
      }
      window.close();
    }
    </script>
    </head>
    <body>
    <div>Processing done.</div>
    </body>
    </html>


  •  

    Posting Permissions

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