Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Submit form to pop-up - why does this code not work?

Reply
Thread Tools

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

 
 
jeff@dnuk.com
Guest
Posts: n/a
 
      09-26-2003
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
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      09-26-2003


http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> 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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
STRUTS- <html:submit> does not submit on pressing Enter key Megha Vishwanath Java 2 10-02-2009 12:52 PM
submit 1 form to 2 servers or 2 forms to 2 server (1 form each) on 1 submit abansal.itp@gmail.com Javascript 3 06-23-2007 07:29 AM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Form submit - hitting enter does not trigger Submit button ASP General 2 10-25-2004 03:37 PM
STRUTS-<html:submit> -Hitting enter key does not submit the form Megha Vishwanath Javascript 3 07-20-2004 05:45 AM



Advertisments