
submiting a form inside an iframe from outside the iframe
This one has me stumped (friday afternoon and I am done!). I am certain it should be done (as long as the iframe content is from the same site). Yet EVERY example I have found online doesn't work in Firefox (not sure about other browsers). I have tried many possible variations. I have other workarounds, but for various reasons I would really like to be able to just have a submit button outside the iframe, that when pressed submits the content of a form inside of the iframe.
Here is just one:
window.frames['myframe'].document.forms['suggestForm'].submit();
Ultimately I get an error saying that there is no submit function, or no properties, etc.
Has anyone done this and can share their code?

NAVIGATION
HomeAbout Me
RSS
Search
Subscribe
Recent Entries
Flash Camp BostonNew Blog Design
Pre-Conference Training at cf.Objective()
FireFox 3.6 KTML Editor Fix
I am now a part of the Adobe Community Professionals Group
Recent Comments
FireFox 3.6 KTML Editor Fix
Fred said: Found another bug in Firefox 3.6
When inserting a table you can't select the number of columns.
So I...
[More]
Repeating Events Question
ueghbxedu said: UaejcB <a href="http://ysyhrmkbkhco.com/&...;, [url=http://pwncz...
[More]
Repeating Events Question
fadxkfyuadn said: n6qVCL <a href="http://bdiorhdtbwzb.com/&...;, [url=http://uvnao...
[More]
FireFox 3.6 KTML Editor Fix
Joshua said: While changing that far will load the editor, does it show the drop down class menu correctly now?
[More]
FireFox 3.6 KTML Editor Fix
Al Johnson said: HI,
I am still fighting to keep my code going as there is nothing better than KTML nad I have writt...
[More]
Calendar
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Archives By Subject
blogs (31) [RSS]books (4) [RSS]
Crazy (39) [RSS]
DIY (8) [RSS]
Flex (3) [RSS]
games (10) [RSS]
GRRR (13) [RSS]
Ideas (11) [RSS]
Local (14) [RSS]
LOLpics (2) [RSS]
money (9) [RSS]
music (3) [RSS]
Personal (27) [RSS]
Photos (8) [RSS]
Politics (8) [RSS]
Projects (22) [RSS]
Review (18) [RSS]
RPM (9) [RSS]
Spam (16) [RSS]
Technology (66) [RSS]
Testing (3) [RSS]
TV (15) [RSS]
video (32) [RSS]
Web Dev (218) [RSS]
World of Warcraft (16) [RSS]

<script type="text/javascript">
/**
*
* SubmitForm function definition:
* Reference the iFrame: var yourVariable = parent.document.getElementById("iFrameNameHere");
* Reference to the window object generated by the the iframe: var yourWindowVariable = yourVariable.contentWindow; //other browsers use contentDocument
* Reference to the form object inside of the iFrame: var theFormObject = yourWindowVariable.document.getElementById("formNameHere");
* Submit the form now :) theFormObject.submit();
*/
function SubmitForm(){
//make a reference to the iFrame;
var iframeElem = parent.document.getElementById("iFrame");
//make a reference to the window of the iFrame (Note: for Mozilla it's diferent you got to use contentDocument instead of contentWindow);
var win = iframeElem.contentWindow;
//make a reference to the form element in the iframe;
var theForm = win.document.getElementById("form1");
//submit the form
theForm.submit();
//just testing
alert("ok");
}
</script>
and this one goes into the end just before closing the body tag:
<script>
/*
*
* Make it available in the DOM
* Reference your submit button
*
*/
var myButton = parent.document.getElementById("submit");
/**
*
* Older method of attaching event:
* myButton.onclick = SubmitForm;
*
*/
/**
*
* IE Hack - attachEvent instead of addEventListener for other browsers
*
*/
myButton.attachEvent('onclick', SubmitForm);
</script>
i've comented the javascript nothing two hard but i hope you understand it
Thanks very much for posting this. Afraid I am still having the same error, in both IE and FF. I tried it in my own code, but also just used your code on a test page. To be clear, my submit button is on the parent frame, not in the iframe. For whatever reason I just can't get at the properties of the iframe form to submit. I get either an object expected error or a iframeElem has no properties error. Pitty.
Try this:
var iframe = window.frames[<FRAMEID>].document.forms[0].submit();
You have to remember though, the contents of your iframe need to be fully loaded for this to work.
That type of error “there is no submit function, or no properties, etc.” can happen when you have an input or button with the name “submit”—change the name to something other than “submit”.