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

<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


<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>
window.parent.form[1].submit();

should be

window.parent.document.form[1].submit();

by the way, you can ommit “window” in this

thanks but still no luck. the parent window isn’t even reloading… is it supposed to???

eric