473,503 Members | 3,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
Jul 20 '05 #1
1 13341


je**@dnuk.com 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/

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1854
by: Matt | last post by:
The problem is I have 3 buttons that need to submit the form to different URL. My approach is to declare <input type="submit"> rather than <input type="button">. And put the following in the...
3
1703
by: Savas Ates | last post by:
<form action="a.asp" method="get" > <input type="image" border="0" src="IMAGES/oklar.jpg"> </form> im usnig this codes to submit form when a user click on oklar.jpg(an image)
3
7008
by: M Wells | last post by:
Hi All, I'm trying to build a page where a user can enter comments and I want to add a 'Preview' button to the form. When the user clicks on the 'Preview' button I'd like the same form to...
15
28916
by: Mattia | last post by:
Hi! I have a <form> that can be submitted thruogh three buttons and I need to tell witch one was pressed when the form was submitted. I now do it with 3 <input type="submit" name="..."...
3
1412
by: Matt | last post by:
When the user click the submit button in myform.asp, then it will invoke the javascript to check the form data. I want to know if we need document.myform.submit(); ?? Because even I comment it...
1
2762
by: Matt | last post by:
The problem is I have 3 buttons that need to submit the form to different URL. My approach is to declare <input type="submit"> rather than <input type="button">. And put the following in the...
1
1972
by: Terence Parker | last post by:
I have a form which enables users to type in some text in a <TEXTAREA>, allowing them to use HTML. I have defined two submit buttons - one to submit as usual, but one which I would like to popup...
1
10492
by: jrefactors | last post by:
When the user type something in text box, and press enter, it will submit the form data to test2.jsp, even without pressing submit form button. This is not what I want, I want to submit the form...
7
2346
by: David T. Ashley | last post by:
Hi, For a web page, I want a SUBMIT button that commits the form data and a CANCEL button that goes to a different target (i.e. a different script). I haven't figured out how to do this,...
23
3188
by: mosesdinakaran | last post by:
Hi All, I need a small clarification in submitting the forms, Ur suggestions please. In a page I have two form and also two submit butons. (ie)
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7063
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7441
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.