?
Solved

iframe and parent window submit

Posted on 2010-03-29
6
Medium Priority
?
278 Views
Last Modified: 2013-12-12
I have a page with an iframe in it, the page contains some textfields and then the iframe.
the iframe has a button for submit. now the user first types the values in textfields then selects items in the iframe and then clicks submit and the page refreshes and the values in textfields is lost
i printed $_POST value, but it just shows the fields in the iframe not the fields in the parent page
the iframe target is set to _top.

hope i am clear with my situation.

thanks.
0
Comment
Question by:Desire2change
  • 4
  • 2
6 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 28963868
Hello Desire2change,

There's no relation between an iframe and its parent container. You are only allowed to change iframe attributes like size and url but not the content.
The iframe _top are not the parent container.

Regards.
0
 

Author Comment

by:Desire2change
ID: 28966279
i just want that when the iframe form is submitted the parent form should also be submitted
0
 
LVL 83

Expert Comment

by:leakim971
ID: 28970857
I understand your need but when you can't, you can't...

If you're ready to use the onload event of the iframe to detect the second time it load (the first time it load with the parent), you can use it to submit the parent form too.

Check this example :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
	var not_the_first_time = 0;
</script>
</head>
<body>
<iframe onload="if( not_the_first_time++ > 0 ) alert('I m loading');"  width="640" height="400" src="http://www.google.com" />
</body>
</html>

Open in new window

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 83

Accepted Solution

by:
leakim971 earned 1500 total points
ID: 28971098
So to submit the parent form :

(you search something on google and when submit the form to get the result you submit the parent too, so we go on EE)


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
	var not_the_first_time = 0;
</script>
</head>
<body>
<form action="http://www.experts-exchange.com" method="GET" >
	<iframe onload="if( not_the_first_time++ > 0 ) document.forms[0].submit();"  width="640" height="400" src="http://www.google.com"  />
</form>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:Desire2change
ID: 31708269
helped me partially
0
 
LVL 83

Expert Comment

by:leakim971
ID: 29083101
Thanks for the points!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question