HighDots Forums  

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

Javascript JavaScript language (comp.lang.javascript)


Discuss Submit form to pop-up - why does this code not work? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jeff@dnuk.com
 
Posts: n/a

Default Submit form to pop-up - why does this code not work? - 09-26-2003 , 07:59 AM






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

Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: Submit form to pop-up - why does this code not work? - 09-26-2003 , 08:04 AM








jeff (AT) dnuk (DOT) com wrote:

Quote:
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;"

--

Martin Honnen
http://JavaScript.FAQTs.com/



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.