auto submit form outside of frame

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

auto submit form outside of frame

Post 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.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: auto submit form outside of frame

Post by VladSun »

How about using the target form attribute? target="_top"
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply