By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,885 Members | 1,322 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,885 IT Pros & Developers. It's quick & easy.

submiting to a parent window from a popup child window?

P: n/a
hi all,
quick question, how do you submit a form to a parent window from a
child popup window? i have the following and all online documentation
*suggests* that it should work but it does NOT:

// Parent window:
<script language="JavaScript">
function popup(url, name)
{
window.open(url, name, "width=800,height=600,scrollbars=yes");
return false;
}
</script>
....
<form name=form1 method=post action=something.php>
<input type=hidden name=h1 value='' >
<a href="#"
target="childWindowName" onclick="return popup('url.php','Some
name');">Pop</a>
....
</form>

// Now in the child popup window
<script language="JavaScript">
function handleSubmit(aValue)
{
var myParent = opener.document.forms.form1;
myParent.h1.value=aValue;
myParent.submit(); // ERROR: Object doesn't support this property
or method
return true;
}
</script>
<a href=# onclick="handleSubmit(2006);">Submit</a>

i have spent a few hours searching online and all the examples
indicates that this example should work but it doesn't, not in IE or
FF. in FF, nothing happen and in IE, the following error show up:

Object doesn't support this property or method

any idea? thanks!

Jun 10 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
anyone? any idea?

mi***************@yahoo.com wrote:
hi all,
quick question, how do you submit a form to a parent window from a
child popup window? i have the following and all online documentation
*suggests* that it should work but it does NOT:

// Parent window:
<script language="JavaScript">
function popup(url, name)
{
window.open(url, name, "width=800,height=600,scrollbars=yes");
return false;
}
</script>
...
<form name=form1 method=post action=something.php>
<input type=hidden name=h1 value='' >
<a href="#"
target="childWindowName" onclick="return popup('url.php','Some
name');">Pop</a>
...
</form>

// Now in the child popup window
<script language="JavaScript">
function handleSubmit(aValue)
{
var myParent = opener.document.forms.form1;
myParent.h1.value=aValue;
myParent.submit(); // ERROR: Object doesn't support this property
or method
return true;
}
</script>
<a href=# onclick="handleSubmit(2006);">Submit</a>

i have spent a few hours searching online and all the examples
indicates that this example should work but it doesn't, not in IE or
FF. in FF, nothing happen and in IE, the following error show up:

Object doesn't support this property or method

any idea? thanks!


Jun 12 '06 #2

P: n/a
First things first, both your pages (parent and child) must be under
the same domain and/or path. If this is the case then it could be that
you gave the window wrong names...
<form name=form1 method=post action=something.php>
<input type=hidden name=h1 value='' >
<a href="#"
target="childWindowName" onclick="return popup('url.php','Some
name');">Pop</a>
...
</form>

where does childWindowName reference to? is it necessary for it to be
there?

'Some name' shouldn't have any spaces in between, so you might want to
consider 'Some_name'

otherwise you could try the onsubmit attribute in form1

mi***************@yahoo.com wrote: anyone? any idea?

mi***************@yahoo.com wrote:
hi all,
quick question, how do you submit a form to a parent window from a
child popup window? i have the following and all online documentation
*suggests* that it should work but it does NOT:

// Parent window:
<script language="JavaScript">
function popup(url, name)
{
window.open(url, name, "width=800,height=600,scrollbars=yes");
return false;
}
</script>
...
<form name=form1 method=post action=something.php>
<input type=hidden name=h1 value='' >
<a href="#"
target="childWindowName" onclick="return popup('url.php','Some
name');">Pop</a>
...
</form>

// Now in the child popup window
<script language="JavaScript">
function handleSubmit(aValue)
{
var myParent = opener.document.forms.form1;
myParent.h1.value=aValue;
myParent.submit(); // ERROR: Object doesn't support this property
or method
return true;
}
</script>
<a href=# onclick="handleSubmit(2006);">Submit</a>

i have spent a few hours searching online and all the examples
indicates that this example should work but it doesn't, not in IE or
FF. in FF, nothing happen and in IE, the following error show up:

Object doesn't support this property or method

any idea? thanks!


Jun 12 '06 #3

P: n/a
comments below...

Seige wrote:
First things first, both your pages (parent and child) must be under
the same domain and/or path. If this is the case then it could be that
you gave the window wrong names...
yes the parent and the child window are under the same domain and same
path.
<form name=form1 method=post action=something.php>
<input type=hidden name=h1 value='' >
<a href="#"
target="childWindowName" onclick="return popup('url.php','Some
name');">Pop</a>
...
</form>

where does childWindowName reference to? is it necessary for it to be
there?


it's not referenced anywhere. correct me if i am wrong (most likely),
target="childWindowName" is the name of the child window and is
required for a popup right? otherwise, i could have use something like
target=_blank

'Some name' shouldn't have any spaces in between, so you might want to
consider 'Some_name'
actually, it doesn't have space in the actual code. iti's my mistake to
have a space here

otherwise you could try the onsubmit attribute in form1

i suppose i could do that but i am more interested to find out why my
solution doesn't work in the first place where all online documentation
and code example suggests that it should. i think you are on the right
track that i must have some sort of name-reference thing mess up
between the child and the parent window but the thing is i can get a
reference of the parent window and setting hidden field variables and
such, it's just the submit() method keep saying it's not support


mi***************@yahoo.com wrote:
anyone? any idea?

mi***************@yahoo.com wrote:
hi all,
quick question, how do you submit a form to a parent window from a
child popup window? i have the following and all online documentation
*suggests* that it should work but it does NOT:

// Parent window:
<script language="JavaScript">
function popup(url, name)
{
window.open(url, name, "width=800,height=600,scrollbars=yes");
return false;
}
</script>
...
<form name=form1 method=post action=something.php>
<input type=hidden name=h1 value='' >
<a href="#"
target="childWindowName" onclick="return popup('url.php','Some
name');">Pop</a>
...
</form>

// Now in the child popup window
<script language="JavaScript">
function handleSubmit(aValue)
{
var myParent = opener.document.forms.form1;
myParent.h1.value=aValue;
myParent.submit(); // ERROR: Object doesn't support this property
or method
return true;
}
</script>
<a href=# onclick="handleSubmit(2006);">Submit</a>

i have spent a few hours searching online and all the examples
indicates that this example should work but it doesn't, not in IE or
FF. in FF, nothing happen and in IE, the following error show up:

Object doesn't support this property or method

any idea? thanks!


Jun 12 '06 #4

P: n/a
Hmm... i'm clueless as to why this happen. Usually when something like
this happens, I would regard it as another "Browser-Securit-Issue" and
proceed with the workaround. (aka onsubmit)

mi***************@yahoo.com wrote:
comments below...

Seige wrote:
First things first, both your pages (parent and child) must be under
the same domain and/or path. If this is the case then it could be that
you gave the window wrong names...


yes the parent and the child window are under the same domain and same
path.
> <form name=form1 method=post action=something.php>
> <input type=hidden name=h1 value='' >
> <a href="#"
> target="childWindowName" onclick="return popup('url.php','Some
> name');">Pop</a>
> ...
> </form>


where does childWindowName reference to? is it necessary for it to be
there?


it's not referenced anywhere. correct me if i am wrong (most likely),
target="childWindowName" is the name of the child window and is
required for a popup right? otherwise, i could have use something like
target=_blank

'Some name' shouldn't have any spaces in between, so you might want to
consider 'Some_name'


actually, it doesn't have space in the actual code. iti's my mistake to
have a space here

otherwise you could try the onsubmit attribute in form1


i suppose i could do that but i am more interested to find out why my
solution doesn't work in the first place where all online documentation
and code example suggests that it should. i think you are on the right
track that i must have some sort of name-reference thing mess up
between the child and the parent window but the thing is i can get a
reference of the parent window and setting hidden field variables and
such, it's just the submit() method keep saying it's not support


mi***************@yahoo.com wrote:
anyone? any idea?

mi***************@yahoo.com wrote:
> hi all,
> quick question, how do you submit a form to a parent window from a
> child popup window? i have the following and all online documentation
> *suggests* that it should work but it does NOT:
>
> // Parent window:
> <script language="JavaScript">
> function popup(url, name)
> {
> window.open(url, name, "width=800,height=600,scrollbars=yes");
> return false;
> }
> </script>
> ...
> <form name=form1 method=post action=something.php>
> <input type=hidden name=h1 value='' >
> <a href="#"
> target="childWindowName" onclick="return popup('url.php','Some
> name');">Pop</a>
> ...
> </form>
>
> // Now in the child popup window
> <script language="JavaScript">
> function handleSubmit(aValue)
> {
> var myParent = opener.document.forms.form1;
> myParent.h1.value=aValue;
> myParent.submit(); // ERROR: Object doesn't support this property
> or method
> return true;
> }
> </script>
> <a href=# onclick="handleSubmit(2006);">Submit</a>
>
> i have spent a few hours searching online and all the examples
> indicates that this example should work but it doesn't, not in IE or
> FF. in FF, nothing happen and in IE, the following error show up:
>
> Object doesn't support this property or method
>
> any idea? thanks!


Jun 12 '06 #5

P: n/a
unfortunetly, onsubmit() won't work too because the form is not
submited so the event is never trigger. i did solve this prolbme by
using this:

// myParent.submit(); -- does NOT work
myParent.mySubmitButton.click(); // this does work

by using the click() event, it does exactly what i need. i still have
no idea why submit() doesn't work.

Seige wrote:
Hmm... i'm clueless as to why this happen. Usually when something like
this happens, I would regard it as another "Browser-Securit-Issue" and
proceed with the workaround. (aka onsubmit)

mi***************@yahoo.com wrote:
comments below...

Seige wrote:
First things first, both your pages (parent and child) must be under
the same domain and/or path. If this is the case then it could be that
you gave the window wrong names...


yes the parent and the child window are under the same domain and same
path.

> > <form name=form1 method=post action=something.php>
> > <input type=hidden name=h1 value='' >
> > <a href="#"
> > target="childWindowName" onclick="return popup('url.php','Some
> > name');">Pop</a>
> > ...
> > </form>

where does childWindowName reference to? is it necessary for it to be
there?


it's not referenced anywhere. correct me if i am wrong (most likely),
target="childWindowName" is the name of the child window and is
required for a popup right? otherwise, i could have use something like
target=_blank

'Some name' shouldn't have any spaces in between, so you might want to
consider 'Some_name'


actually, it doesn't have space in the actual code. iti's my mistake to
have a space here

otherwise you could try the onsubmit attribute in form1


i suppose i could do that but i am more interested to find out why my
solution doesn't work in the first place where all online documentation
and code example suggests that it should. i think you are on the right
track that i must have some sort of name-reference thing mess up
between the child and the parent window but the thing is i can get a
reference of the parent window and setting hidden field variables and
such, it's just the submit() method keep saying it's not support


mi***************@yahoo.com wrote:
> anyone? any idea?
>
> mi***************@yahoo.com wrote:
> > hi all,
> > quick question, how do you submit a form to a parent window from a
> > child popup window? i have the following and all online documentation
> > *suggests* that it should work but it does NOT:
> >
> > // Parent window:
> > <script language="JavaScript">
> > function popup(url, name)
> > {
> > window.open(url, name, "width=800,height=600,scrollbars=yes");
> > return false;
> > }
> > </script>
> > ...
> > <form name=form1 method=post action=something.php>
> > <input type=hidden name=h1 value='' >
> > <a href="#"
> > target="childWindowName" onclick="return popup('url.php','Some
> > name');">Pop</a>
> > ...
> > </form>
> >
> > // Now in the child popup window
> > <script language="JavaScript">
> > function handleSubmit(aValue)
> > {
> > var myParent = opener.document.forms.form1;
> > myParent.h1.value=aValue;
> > myParent.submit(); // ERROR: Object doesn't support this property
> > or method
> > return true;
> > }
> > </script>
> > <a href=# onclick="handleSubmit(2006);">Submit</a>
> >
> > i have spent a few hours searching online and all the examples
> > indicates that this example should work but it doesn't, not in IE or
> > FF. in FF, nothing happen and in IE, the following error show up:
> >
> > Object doesn't support this property or method
> >
> > any idea? thanks!


Jun 13 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.