Skip to main content

Working with forms inside iframes



I was requested to do some work with forms using the iframes on a web page and it was needed to do a lot of Googling and thought to share those things.


1. Display a form on the main page and when the form is submitted the results should be shown on an iframe on the same page.
a. This task was pretty simple and what I had to do is give the same page as the action page of the form.
b. If the form data is defined on the page I had to show the iframe.When showing the iframe I had to give all the form data as query parameters on the URL of the iframe.

c. Then the resulting page was displayed correctly inside the iframe.
2. Then the resulting page which was inside the iframe was also a web form and it has to be submitted on the event of a button click which was on the main page.
a. For the button click event we have to fire a JavaScript function.

b. On that JavaScript function we can do the submission as follows.
 
c. This will be doing the submission and we have to redirect the resulting page to the same one.
3. When showing the resulting page inside the iframe we have to update the resulting values according to the values on the main page.
a. For that we have to submit the form again when we are showing the resulting page.
b. So we have to send a query parameter and if the query parameter is true then we have to do the main page form submission.

4. If we need o call a JavaScript function on main page on an event of something whch was palced inside the iframe we can call like,
onclick = “return parent.functionName(parameter)”
Hope this may help you when working with iframes and if there are better ways to do this or if something goes wrong (nobody is perfect) please do share it with me.

Comments

  1. The parent will not work with the pop-up windows.

    Which means you can not access parent window as parent so we have to use window.opener to get the parent window of a pop-up.

    ReplyDelete

Post a Comment

Popular posts from this blog

Google API v3 with PHP using Blogger service

It was really hard for me to understand how the Google APIs are working at the first point and took few days for me to figure out. But after a successful working prototype it seems very easy. And also when I am searching for a simple example I was unable to find a good one that I can understand. So let me list down step by step what I have done with URLs and as simple as I can. Create a Google app location -  https://code.google.com/apis/console Switch on the "Blogger API v3" Get the latest APIs client library for PHP location -  https://code.google.com/p/google-api-php-client/downloads/list Upload the files to your host location on on localhost Extract the files to folder  named "GoogleClientApi" Create your php file outside of the folder  Copy paste following code into the file and do the changes as needed  By changing the scope and the service object you can access all the services that is given by Google APIs through the PHP API library se

My two cents on new year resolution

What is the plan for the new year ? - need to think on what are we trying achieve during next year 2018 - basically the life goals - may be personal or professional - and also it should be realistic (not something like going to Mars ;)) Why we need a plan for the new year ? - basically a goal without a plan is a DREAM - And also should be able to measure (what you cannot measure, you cannot manage) How to prepare a new Year resolution/plan ? - Leave some buffer time - Make changes during the year (life is changing/evolving) - Plan is only for you (do not share it) - When a milestone is achieved, celebrate - Try to stick to the plan - otherwise no point of planing

Assets and Liabilities as Rich Dad, Poor Dad explains

I was reading "The rich dad poor dad by Robert Kiyosaki" here is a one point that he mentions on that. Basically Asset as he says is little bit different than on books. If something puts money in your pocket it is a asset. And Liabilities are the ones that takes money out of your pocket. OK for example a house or a car may seems like an Asset but it takes money out of you pocket to maintain them. But if you rent them or make them to make money at the end of the day you can convert it to a asset. Basically that what rich people do. They buy assets. Middle class buy liabilities (thinking those are assets) and stuff (a lot of them that not used or that not needed). Lower class buy to consume (basic needs like foods).