Link to home
Start Free TrialLog in
Avatar of stewmic1
stewmic1

asked on

Problem with document.submit to a pop-up window.

The following code works, but for a brief second, the pop-up window shows a "Page Cannot be Found" error before then loading the page.  

passwindow=window.open("http://earchicture.inl.gov/rev_questions.sel2_questions","passwindow","width=700,height=800,toolbar=no,resizable=yes,menubar=yes,scrollbars=yes");
document.form2.target = "passwindow";
document.form2.submit();
 
I've tried:
var set_timeout=setTimeout("document.form2.submit();",500);
But it didn't solve my problem.

Open in new window

Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Please show the form too

If you have a target="passwindow" on the form I wonder which of the urls you see, the action (not found) and then the scripted one - I suggest you remove the url from the script:
function submitFormScript() {
  passwindow=window.open("","passwindow","width=700,height=800,toolbar=no,resizable,menubar,scrollbars");
  document.form2.target = "passwindow";
  document.form2.submit();
}

How do you call the script?

If

input type="submit" onClick="submitFormScript()"

then you are in trouble.

Instead use a button or even better put the url in the action and return false in the onSubmit

ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stewmic1
stewmic1

ASKER

The form is hidden and needs to be submitted via Javascript.
The script is called when the user clicks on a radiobutton using onChange() .
My code will work on a hidden form too...
There is no onChange on a radio. Use onClick

function submitFormScript(theForm) {
  passwindow=window.open("",theForm.target,"width=700,height=800,toolbar=no,resizable,menubar,scrollbars");
  setTimeout('document.forms["'+theForm.name+'"].submit()',500);
}
 
 
<form name="form2" action="http://earchicture.inl.gov/rev_questions.sel2_questions" 
target="passwindow">
.
.
<input type="radio" onClick="submitFormScript(this.form)" />
</form>

Open in new window

You're right... it is on click.  Here is what I have using your code.  It's now submitting to a blank page.  Obviously, the action is not firing.  Don't mind the htp.p and owa statements... I am using the PL/SQL web cartridge.

the form:
htp.p('');

the script:

htp.p('passwindow=window.open("",document.form2.target,"width=700,height=800,toolbar=no,resizable,menubar,scrollbars");');
 htp.p('setTimeout(document.forms["+document.form2+"].submit(),500);');
Why not show the actual HTML (view-source) the cartridge produces in the browser???
mplungian... You gave me enough of an answer to help me solve this problem.