![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I am trying to submit a form in a parent window by using its child window. Given there are a parent window and a child window, child window has code like this: function submitOpenerForm(){ var ope = window.opener.document.getElementById("input1").va lue = "hardcode"; window.opener.document.getElementById("btn1").clic k(); window.close(); } The code works for submitting but the parent window always refresh after that, my question is, how can it click the button, processing the form submit, but the parent page will not refresh? For some reason, I can't use window.opener.document.getElementById ('form1').sumbit() bla bla to submit that form. I know Ajax can submit form without refresh the page, but it needs a url, and those data, my case is that, I am not sure those data are (or are from which fields,input,so on), but I do know there is an input element needed to be assigned value and there is only a submit button. Is there any way I can prevent it refreshing the page after click()? |
#3
| |||
| |||
|
|
SamuelXiao schreef: Hi, I am trying to submit a form in a parent window by using its child window. Given there are a parent window and a child window, child window has code like this: function submitOpenerForm(){ * *var ope = window.opener.document.getElementById("input1").va lue = "hardcode"; * *window.opener.document.getElementById("btn1").cli ck(); * *window.close(); } The code works for submitting but the parent window always refresh after that, my question is, how can it click the button, processing the form submit, but the parent page will not refresh? For some reason, I can't use window.opener.document.getElementById ('form1').sumbit() bla bla to submit that form. I know Ajax can submit form without refresh the page, but it needs a url, and those data, my case is that, I am not sure those data are (or are from which fields,input,so on), but I do know there is an input element needed to be assigned value and there is only a submit button. Is there any way I can prevent it refreshing the page after click()? Hi, Did you put a target="nameofchildwindow" in the form on your parentpage? Regards, Erwin Moller -- "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." -- C.A.R. Hoare |
#4
| ||||||||
| ||||||||
|
|
Hi, I am trying to submit a form in a parent window |
|
by using its child window. Given there are a parent window and a child window, child window has code like this: function submitOpenerForm(){ |
|
var ope = window.opener.document.getElementById("input1").va lue = "hardcode"; |
|
window.opener.document.getElementById("btn1").clic k(); window.close(); |
|
} The code works for submitting but the parent window always refresh |
|
after that, my question is, how can it click the button, processing the form submit, but the parent page will not refresh? For some reason, I can't use window.opener.document.getElementById ('form1').sumbit() bla bla to submit that form. |
|
I know Ajax can submit form without refresh the page, but it needs a url, and those data, my case is that, I am not sure those data are (or are from which fields,input,so on), but I do know there is an input element needed to be assigned value and there is only a submit button. |
|
Is there any way I can prevent it refreshing the page after click()? |
#5
| |||
| |||
|
|
On Nov 3, 10:42 pm, Erwin Moller Since_humans_read_this_I_am_spammed_too_m... (AT) spamyourself (DOT) com> wrote: SamuelXiao schreef: Did you put a target="nameofchildwindow" in the form on your parentpage? No, for calling child window in the parent, I use a function like the following: |
|
function mypopup() { mywindow = window.open ("xxx.jsp", "mywindow","width=100,height=100"); mywindow.moveTo(0,0); } when click a button "popup"; |
#6
| |||
| |||
|
|
if(typeof mywindow == undefined [...] |
#7
| |||
| |||
|
|
On Nov 3, 10:42 pm, Erwin Moller Since_humans_read_this_I_am_spammed_too_m... (AT) spamyourself (DOT) com> wrote: SamuelXiao schreef: Hi, I am trying to submit a form in a parent window by using its child window. Given there are a parent window and a child window, child window has code like this: function submitOpenerForm(){ var ope = window.opener.document.getElementById("input1").va lue = "hardcode"; window.opener.document.getElementById("btn1").clic k(); window.close(); } The code works for submitting but the parent window always refresh after that, my question is, how can it click the button, processing the form submit, but the parent page will not refresh? For some reason, I can't use window.opener.document.getElementById ('form1').sumbit() bla bla to submit that form. I know Ajax can submit form without refresh the page, but it needs a url, and those data, my case is that, I am not sure those data are (or are from which fields,input,so on), but I do know there is an input element needed to be assigned value and there is only a submit button. Is there any way I can prevent it refreshing the page after click()? Hi, Did you put a target="nameofchildwindow" in the form on your parentpage? Regards, Erwin Moller -- "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." -- C.A.R. Hoare No, for calling child window in the parent, I use a function like the following: function mypopup() { mywindow = window.open ("xxx.jsp", "mywindow","width=100,height=100"); mywindow.moveTo(0,0); } when click a button "popup"; |
#8
| |||
| |||
|
|
Le 11/3/09 3:14 PM, SamuelXiao a écrit : Hi, I am trying to submit a form in a parent window It's not exactly a "parent". by using its child window. Given there are a parent window and a child window, child window has code like this: function submitOpenerForm(){ if(window.opener) { * *var ope = window.opener.document.getElementById("input1").va lue = "hardcode"; window.opener.document.getElementById("input1").va lue = "hardcode"; * *window.opener.document.getElementById("btn1").cli ck(); * *window.close(); * * } } The code works for submitting but the parent window always refresh Normal, it's the default behavior. In the parent : form id="form1" name="form1" target="other" action="mytest.php" that will send the form in a new window (same window at each new try) Notice: that way of doing is deprecated (If I'm not in error) after that, my question is, how can it click the button, processing the form submit, but the parent page will not refresh? For some reason, I can't use window.opener.document.getElementById ('form1').sumbit() bla bla to submit that form. The form has it an ID ? (and that id is named 'form1' ?) Try : * * document.forms['form1'].submit(); instead, if the form has only a name. I know Ajax can submit form without refresh the page, but it needs a url, and those data, my case is that, I am not sure those data are (or are from which fields,input,so on), but I do know there is an input element needed to be assigned value and there is only a submit button. You don't need a physical submit button when you do : * *document.forms[0].submit() Is there any way I can prevent it refreshing the page after click()? The file called by the action of the form must be send somewhere : - in same window (default) - a new window ( target="_blank" -or- target="noname" -or- JS function) - a frame or iframe Or you avoid the action : * *<form onsubmit="return false;" blah... but it isn't your purpose, no ? function submitOpenerForm(){ * if(window.opener) { * * *var ope = window.opener.document.forms["form1"]; * * *ope.elements["input1"].value = "hardcode"; * * *ope.target = 'other'; * * *ope.submit(); * * *window.opener.focus(); // probably not useful * * *self.close(); * * *} * else alert('Mother is closed'); } -- sm |
#9
| |||
| |||
|
|
SamuelXiao schreef: On Nov 3, 10:42 pm, Erwin Moller Since_humans_read_this_I_am_spammed_too_m... (AT) spamyourself (DOT) com> wrote: SamuelXiao schreef: Hi, I am trying to submit a form in a parent window by using its child window. Given there are a parent window and a child window, child window has code like this: function submitOpenerForm(){ * *var ope = window.opener.document.getElementById("input1").va lue = "hardcode"; * *window.opener.document.getElementById("btn1").cli ck(); * *window.close(); } The code works for submitting but the parent window always refresh after that, my question is, how can it click the button, processing the form submit, but the parent page will not refresh? For some reason, I can't use window.opener.document.getElementById ('form1').sumbit() bla bla to submit that form. I know Ajax can submit form without refresh the page, but it needs a url, and those data, my case is that, I am not sure those data are (or are from which fields,input,so on), but I do know there is an input element needed to be assigned value and there is only a submit button. Is there any way I can prevent it refreshing the page after click()? Hi, Did you put a target="nameofchildwindow" in the form on your parentpage? Regards, Erwin Moller -- "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." -- C.A.R. Hoare No, for calling child window in the parent, I use a function like the following: function mypopup() *{ * * *mywindow = window.open ("xxx.jsp", * * *"mywindow","width=100,height=100"); * * *mywindow.moveTo(0,0); *} when click a button "popup"; Hi, As SAM wrote: That isn't important. What is important is where the form should be posted. If you don't give a target for the form, the form ALWAYS posts to the window that contains that form. If you want it to post somewhere else (or better formulated: "If you want the response from the server-that-processes-the-form to appear somewhere else") you SHOULD use target. The value you give to target should be the name of that window/frame. Mind you that using a target is a sin if you use strict doctype. Regards, Erwin Moller -- "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." -- C.A.R. Hoare- Hide quoted text - - Show quoted text - |
#10
| |||
| |||
|
|
On Nov 3, 11:57 pm, Erwin Moller Since_humans_read_this_I_am_spammed_too_m... (AT) spamyourself (DOT) com> wrote: SamuelXiao schreef: On Nov 3, 10:42 pm, Erwin Moller Since_humans_read_this_I_am_spammed_too_m... (AT) spamyourself (DOT) com> wrote: SamuelXiao schreef: Hi, I am trying to submit a form in a parent window by using its child window. Given there are a parent window and a child window, child window has code like this: function submitOpenerForm(){ var ope = window.opener.document.getElementById("input1").va lue = "hardcode"; window.opener.document.getElementById("btn1").clic k(); window.close(); } The code works for submitting but the parent window always refresh after that, my question is, how can it click the button, processing the form submit, but the parent page will not refresh? For some reason, I can't use window.opener.document.getElementById ('form1').sumbit() bla bla to submit that form. I know Ajax can submit form without refresh the page, but it needs a url, and those data, my case is that, I am not sure those data are (or are from which fields,input,so on), but I do know there is an input element needed to be assigned value and there is only a submit button. Is there any way I can prevent it refreshing the page after click()? Hi, Did you put a target="nameofchildwindow" in the form on your parentpage? Regards, Erwin Moller -- "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." -- C.A.R. Hoare No, for calling child window in the parent, I use a function like the following: function mypopup() { mywindow = window.open ("xxx.jsp", "mywindow","width=100,height=100"); mywindow.moveTo(0,0); } when click a button "popup"; Hi, As SAM wrote: That isn't important. What is important is where the form should be posted. If you don't give a target for the form, the form ALWAYS posts to the window that contains that form. If you want it to post somewhere else (or better formulated: "If you want the response from the server-that-processes-the-form to appear somewhere else") you SHOULD use target. The value you give to target should be the name of that window/frame. Mind you that using a target is a sin if you use strict doctype. Regards, Erwin Moller Hi, do you know how I can submit to a target that will not popup a new window and not the current window? Iframe seems to be the solution, but I am not allowed to use it. |
![]() |
| Thread Tools | |
| Display Modes | |
| |