{"id":4014,"date":"2017-02-07T12:07:09","date_gmt":"2017-02-07T17:07:09","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=4014"},"modified":"2021-12-08T13:06:54","modified_gmt":"2021-12-08T18:06:54","slug":"post-html-form-data-iframe","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/post-html-form-data-iframe\/","title":{"rendered":"How to Post HTML Form Data to an iFrame"},"content":{"rendered":"\n
Some newbie web designers<\/a> tend to overthink solutions to simple problems. One such problem is how to post HTML<\/a> form data to an iFrame.<\/p>\n\n\n\n The situation goes that in some situations you may want to have an iFrame embedded<\/a> in a parent page and post the contents of a form to return a response in the iFrame.<\/p>\n\n\n\n At this point, many designers retreat to some form of JavaScript be it jQuery or any other solution. The good news is that we can keep things simple and not resort to other secondary methods at hand.<\/p>\n\n\n\n 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.<\/p>\n\n\n\n Here is a gist that shows you how the code should look like.<\/p>\n\n\n\n This solution will only work for an iFrame embedded on the same page which has the form. Here is a solution<\/a> that allows you to post HTML form data to another web<\/a> page.<\/p>\n","protected":false},"excerpt":{"rendered":" Some newbie web designers tend to overthink solutions to simple problems. One such problem is how to post HTML form data to an iFrame. The situation goes that in some…<\/p>\n","protected":false},"author":1,"featured_media":4015,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,20],"tags":[303,307,635,637],"yoast_head":"\nSo how do I Post HTML Form Data to an iFrame Without JavaScript<\/h2>\n\n\n\n
<form action="iframe-source.php" target="iframe-name" method="post">\n\t\t\t\n <label for="text">Input Label:<\/label>\n <input type="text" name="text" id="text">\n <input type="submit" value="Submit">\n\t\t\t\n<\/form>\n\t\t<!-- some more HTML here. -->\n<iframe name="iframe-name" src="iframe-source.php"><\/iframe><\/code><\/pre>\n\n\n\n