What works:

I have a customer statement that get displayed. It's shows the sub-total, commissions and the total.

I have a link that says 'add adjustment'. A new window (javascript) pops-up with the input fields.

What I need help with:

After filling in the appropriate fields, the user will click submit. I want the window underneath (the one that launched this window) to refresh to hit the database with the posted results and show the changes.

Any ideas?

Regards,
a9

    Try: opener.window.reload(true);

      Works like a charm, thanks. Do you know how to prevent the browser asking the user to retry or cancel?

        If your original window is receiving form data, I don't think you can. Let know if you find out otherwise, I know a few people who are running into the same thing.

        Here is one workaround: Try submitting the data before the confirmation page. This way the confirmation page retrives the data directly from the DB not the post/get method. That means another page to actually do the form proccessing stuff, but leaves the ability to refresh your confirm page without errors.

        That's how I've been doing it, though I could be way off.🙂

        P.S.
        You can refresh the window by using "opener.location.reload(true);" as well.

          play with these, in conjunction with onSubmit/onClick:

          function redirectParent(url)
          {
          window.opener.location.href = url;
          }
          
          function reloadParent()
          {
          window.opener.location.href = window.opener.location;
          }
          

            Your right, there is no way of doing it, because you can't specify another [already open] window as the target in the form tag.

            What I did was this:

            1. Submitted the form's results to PHP_SELF.

            Then used this code at the top of my form:

            if (isset($_POST['adjust'])) {
            
            $adj_q = "UPDATE my_table SET ";
            if ($_POST['field1'] != NULL) $adj_q .= "field1='$_POST[field1]', ";
            if ($_POST['field2'] != NULL) $adj_q .= "field2='$_POST[field2]', ";
            if ($_POST['field3'] != NULL) $adj_q .= "field3='$_POST[field3]', ";
            
            $adj_q = substr($adj_q, 0, -2);
            $adj_q .= " WHERE ID='$_POST[ID]' AND sale_date='$_POST[date]'";
            
            mysql_query($adj_q) or showerror();
            
            print "<script>javascript: opener.location.href('settlement.php?create=true&ID=$_POST[ID]&date=$_POST[date]'); self.close()</script>";
            }
            

            The opener window get the variables from a $_GET, checks to see if adjustment results are in the database, is refreshed to show the results, and the submitting form gets closed. All transparent to the user.

            Thanks for all the ideas!

              Write a Reply...