POST Data From a Form To An iFrame

July 28th, 2012 - Posted by Steve Marks to (X)HTML / CSS, Web Development.

You’re probably used to submitting forms to the same page or to a new window by setting the target of a form to ‘_self’ (or not setting a ‘target’ attribute) or ‘_blank’.

If you use iFrames however, be it as an interface element or a hidden element, there might be a time when you need to submit a form on an outer page and send the data to an iFrame used within the same page.

This can be easily acheived by using the ‘target’ attribute on the form I mentioned above and setting it to the name of the iFrame. Let me provide you with a very simple example of this below:


   <form name="form1" action="iframe_page.php" target="myIframe" method="POST">
   <!-- Form Elements Here -->
   <iframe src="" name="myIframe></iframe>


In the example above, when our form is submitted, the data would be POST’ed to a file called iframe_page.php in the iFrame called ‘myIframe’.

This entry was posted on Saturday, July 28th, 2012 at 1:19 pm by +Steve Marks and is filed under (X)HTML / CSS, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.

Fear not, we won't publish this

Comments (1)
  1. dad says:

    Hello,, That was very helpful