 |
Javascript General Javascript discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

June 2nd, 2004, 02:48 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Forcing a form in the parent's parent to submit
This is the situation: I have a page with a form. In this page is an iframe. In this iframe is a frames page, and in one of the frames is a function that forces the form in the parent-est page to submit, but it doesn't work.
I am using IE6, and it pops up an error message oddly without the line, error number and description. Then it pops up another error box that says "an error has occured in this dialog: error 84, unspecified error."
Here is my code:
Code:
HTML_to_export = doc.body.innerHTML;
parent.parent.document.open();
//this line causes it. without this line I get parent.parent is not an object
parent.parent.document.forms[0].newvalue.value = HTML_to_export;
parent.parent.document.forms[0].submit();
Has anyone else encountered this problem?
Thanks,
Snib
<><
|

June 2nd, 2004, 03:52 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
Basically you're saying that you have a nested frame many frames down. If you want the topmost frame, then the "top" property should do it.
top.document.forms[0].submit();
HTH!
Regards,
Rich
::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
|

June 2nd, 2004, 04:10 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Rich: same thing happens, replacing all parent.parent with top.
Thanks for helping,
Snib
<><
|

June 2nd, 2004, 08:21 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Let me add some info....
These work:
alert(parent.parent.location);
alert(top.location);
None of these do:
document.forms['myform']....
document.forms[0]....
document.forms.myform....
document.myform....
They all return something like "document.forms[...] is null or not an object".
Thanks in advance.
Snib
<><
|

June 3rd, 2004, 11:26 AM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
FYI, I solved this problem.
I don't know what was wrong, but I used a workaround: I made a form in the window that contains the force submit function, and gave it the attribute target="_top". It all works now!
Thanks,
Snib
<><
|

June 21st, 2004, 05:55 PM
|
Registered User
|
|
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi, I'd love to know more about how you resolved this issue as I am having the same one. I have a form with an iframe that contains another form. I need to be able to submit the top level form when a button is clicked (after the button has executed it's server side code). Any help is appreciated. Thanks.
|

June 22nd, 2004, 10:42 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
Dear TammyWoods:
Have u ever check Target attribute on [u]Form</u>
Always:),
Hovik Melkomian.
|

June 22nd, 2004, 11:03 AM
|
Registered User
|
|
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I tried using the target attribute, but what happened there was the form in the iframe popped up into a new page.... it didn't work... so I must be missing something here?
|

June 22nd, 2004, 11:06 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
NO u should use ur Frame name for Target.
Always:),
Hovik Melkomian.
|

June 22nd, 2004, 01:47 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
I set my target attribute to _top.
HTH,
Snib
<><
|
|
 |