Page 1 of 1

auto submit form outside of frame

Posted: Tue Nov 09, 2010 2:21 am
by PHPycho
Hi i have a form inside a frame, for example:

Code: Select all

<html>
<body>
<div><h1>Header</h1><hr /></div>
<iframe height="75%" width="75%" src="iframe.php" frameborder="0">
Iframe should be enabled.
</iframe>
<div><hr /><h1>Footer</h1></div>
</body></html>
in iframe.php

Code: Select all

<form action="http://some-url" id="my_form" name="my_form" method="POST">
<!-- hidden fields goes here --->
<input id="<?php echo $key; ?>" name="<?php echo $key; ?>" value="<?php echo $value; ?>" type="hidden"/>
<!-- //hidden fields goes here --->
</form>
<script type="text/javascript">document.getElementById("my_form").submit();</script>
I would like to know how to submit the iframe.php form so that it goes out of frame.
I think we need to tweak this code:

Code: Select all

<script type="text/javascript">document.getElementById("my_form").submit();</script>
Thanks in advance.

Re: auto submit form outside of frame

Posted: Tue Nov 09, 2010 5:32 am
by VladSun
How about using the target form attribute? target="_top"