Refresh or close after form submission

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • htmlnoob112233
    New Member
    • Jun 2009
    • 20

    #16
    Where would I put that thought.

    Its part of the design.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #17
      You can put it in the form action page:
      Code:
      window.onload = function() {
          parent.location.reload();
      }

      Comment

      • htmlnoob112233
        New Member
        • Jun 2009
        • 20

        #18
        Thank you very much.
        Thats the one.. nearly, as this runs the whole page in a loop :P
        I just added
        Code:
        framename.document.
        So the whole code reads

        Code:
        window.onload = function() { 
            parent.framename.document.location.reload(); 
        }
        Once again, thank you very much for your help, I do appreciate it. :)

        Comment

        • htmlnoob112233
          New Member
          • Jun 2009
          • 20

          #19
          The only problem I have is that it makes the target frame a bit jumpy when it loads as it has to load twice the first time round (initial load, and refresh).

          So is it possible to only run the script when the button is submitted?
          I have tried the following but it did not work.
          Code:
          <input type="submit" value="Go" onSubmit="parent.framename.document.location.reload();">

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #20
            Use PHP code to decide if the code should exist. Only have the JavaScript code run if the form has been submitted, e.g.
            Code:
            <?php 
                if (isset(...)) {
            ?>
            <script type="text/javascript">
            ...
            </script>
            <?php
                }
            ?>

            Comment

            • htmlnoob112233
              New Member
              • Jun 2009
              • 20

              #21
              It does not refresh when clicked, what have I done wrong?

              This is the code in the form frame.

              Code:
              <?php  
                  if (isset($var)) { 
              ?> 
              <script type="text/javascript"> 
              $var window.onload = function() {  
                  parent.frameName.document.location.reload();  
              }  
              </script> 
              <?php 
                  } 
              ?>

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #22
                No, it doesn't quite work like that. You need to replace $var with the posted variable in PHP, e.g. $_POST['submit']. Also remove $var on line 5. If you have any more problems on that front, ask in the PHP forum.

                Comment

                Working...