SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Busch's Avatar
    Join Date
    Jan 2004
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    submit parent form when iframe form is submitted

    i've been playing with this for a few weeks but no luck.

    i want the parent frame form to be submitted when the iframe form is submitted.

    here's what i have so far but no luck (i am echoing the $_POST info to check if the form is getting submitted).

    main page
    PHP Code:
    <html lang="en">
    <head>
    </head>
    <body>

    <iframe src="iframe.php" name="frame1" scrolling="auto"></iframe>

    <h1>
    <?php
    if ($_POST['field1'] != '') {
        echo 
    $_POST['field1'] . "<br />";
    }
    ?></h1>
    <form method="post" name="form1" id="form1" action="index.php">
    field1: 
    <input name="field1" value="<?php echo $_POST['field1']; ?>" type="text"><br />
    <input type="submit" name="submit" value="submit">
    </form>

    </body>
    </html>

    iframe page
    PHP Code:
    <html lang="en">
    <head>
    </head>
    <body>

    <script type="text/javascript">
    <!--
    function submitform()
    {
        window.parent.form[1].submit();
        return true;
    }
    //-->
    </script>

    <h1>
    <?php
    if ($_POST['field2'] != '') {
        echo 
    $_POST['field2'] . " - " $_POST['field1'];
    }
    ?></h1>
    <form method="post" name="form2" id="form2">
    field1: <input name="field2" value="<?php echo $_POST['field2']; ?>" type="text"><br />
    <input type="submit" name="submit" value="submit" onclick="submitform()">
    </form>

    </body>
    </html>

  2. #2
    SitePoint Enthusiast Tygatur's Avatar
    Join Date
    Apr 2006
    Location
    Germany
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    window.parent.form[1].submit();
    should be

    HTML Code:
    window.parent.document.form[1].submit();
    by the way, you can ommit "window" in this
    to code or not to code ?
    that's too much of a question for a signature.

  3. #3
    SitePoint Wizard Busch's Avatar
    Join Date
    Jan 2004
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks but still no luck. the parent window isn't even reloading... is it supposed to???

    eric


Bookmarks

Posting Permissions

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