[Javascript] submit a form from another frame

Peter Brunone peter at brunone.com
Mon Aug 5 01:23:15 CDT 2002


	Try using the form name instead, as well as the collection names.

top.frames.contentFrame.document.forms.formName.submit();

	When in doubt, be as explicit as possible.  If it still doesn't work, we'll
look at some more code.

Cheers,

Peter

|-----Original Message-----
|From: javascript-admin at LaTech.edu [mailto:javascript-admin at LaTech.edu]On
|Behalf Of maciej.kaniewski at lido.net
|
|Hi all,
|
|I'm aware that there were a lot of topics on this list regarding submit
|problem, but unfortunately I couldn't find a solution for my problem.
|
|My webpage has a few frames. One of them is called "contentFrame". I've got
|another one which is a menu frame.
|Let's assume I want to have a hyperlink in my menu frame, which submits the
|current page in the contentFrame (don't ask me why I want to have like
|this. It a bit more complicated.)
|My page which is loaded into the contentFrame has only one form, called
|'contentForm'.
|How can I do that?
|
|My menu file is very simple
|
|<html>
|<head>
|<script language="javascript">
|function doSubmit()
|{
|      if( parent.contentFrame.formChanged )
|      {
|            alert(parent.contentFrame.document.forms[0].name ' is going to
|be submitted');
|            parent.contentFrame.document.forms[0].submit();
|            alert('submit method invoked');
|      }
|}
|</script>
|</head>
|<body>
|<a href="javascript:doSubmit();">SUBMIT</a>
|</body>
|</html>
|
|The reason why I have additional doSubmit method is to check if the form
|has been changed or not (in fact to check if I need to submit or not).
|Once I enter some value in the text input field in the contentForm, my
|formChanged flag is set to true. THen if I click on SUBMIT hyperlink in the
|menu frame, I can see the alert window with the text "contentForm is going
|to be submitted" and then I have an JS error: "Object doesn't support this
|property or method"
|Why????????
|
|Any suggestions are welcome
|thanks in advance
|
|Maciek
|




More information about the Javascript mailing list