Submit form to pop-up - why does this code not work?

J

jeff

I want to press a submit button on a form and then a pop-up Window opens
to process the form data.


I have a form with this HTML code:

<form action="/test.php" method="post" name="testform" onSubmit="newWindowForm('testform')">


And here is the javascript for the top of the page:

function newWindowForm(formname)
{
//alert(formname);
var popUp = window.open ('','popUp','scrollbars=no,resizable=no,width=450,height=350');
document.formname.target = 'popUp';
}


The problem is this line:

document.formname.target = 'popUp';


I've obviously got the syntax wrong. I've checked that the "formname" parameter
is being passed to the javascript, it is. You can test it by using the
"alert(formname);" line to see what it is.

A quick way to fix this is to harcode the formname into the javascript:

document.testform.target = 'popUp';


However, there will be lots of these forms in my website and I want
to use 1 piece of code for each form, instead of coding each javascript.

Can this be done?

Cheers
 
M

Martin Honnen

I want to press a submit button on a form and then a pop-up Window opens
to process the form data.


I have a form with this HTML code:

<form action="/test.php" method="post" name="testform" onSubmit="newWindowForm('testform')">


And here is the javascript for the top of the page:

function newWindowForm(formname)
{
//alert(formname);
var popUp = window.open ('','popUp','scrollbars=no,resizable=no,width=450,height=350');
document.formname.target = 'popUp';
}


The problem is this line:

document.formname.target = 'popUp';

I guess you want
<form target="windowName"
onsubmit="window.open('', this.target, 'width=...');
return true;"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top