Link to home
Start Free TrialLog in
Avatar of Desire2change
Desire2change

asked on

iframe and parent window submit

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.
Avatar of leakim971
leakim971
Flag of Guadeloupe image

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.
Avatar of Desire2change
Desire2change

ASKER

i just want that when the iframe form is submitted the parent form should also be submitted
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

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
helped me partially
Thanks for the points!