The situation goes that in some situations you may want to have an iFrame embedded in a parent page and post the contents of a form to return a response in the iFrame.
The solution is simple. All one needs to do is set the iFrame as a target in form tags. The target should then point to the name of the iFrame. The action should be the same file as the iFrame source.
Here is a gist that shows you how the code should look like.
<form action="iframe-source.php" target="iframe-name" method="post"> <label for="text">Input Label:</label> <input type="text" name="text" id="text"> <input type="submit" value="Submit"> </form> <!-- some more HTML here. --> <iframe name="iframe-name" src="iframe-source.php"></iframe>