473,651 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Submit form to different script & window

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 another window and
submit the typed text to different action/script to give a preview.

So far I have done this (removing the excess formatting HTML for clarity):

----------
<SCRIPT language="JavaS cript" type="text/javascript">
function submitForm(t) {
window.open("", t, "width=500,heig ht=450");
return true
}
</SCRIPT>
<form action="user_me ssage.php" method="POST" name="UserMessa ge">
<textarea cols="55" rows="15" name="content"> </textarea>
<INPUT type="submit" value="Modify Message">
</form>

<form method="POST" name="Preview" action="preview _message.php"
onsubmit="retur n submitForm(this .target)" target="preview ">
<input type="hidden" name="content" value="">
<input type="submit" name="submit" value="Preview Message">
</form>
-----------

The normal submit obviously works ; the 'preview' submit successfully
pops up another window but because it is submitting a different form it
doesn't contain the value of my textarea.

I have tried adding:
document.form.P review.content. value =
document.form.U serMessage.cont ent.value;

- but this did not work. In fact, this resulted in the popup losing its
attributes too (i.e. not Hx500;Wx450).

I've also considered putting the 'preview' button as part of the first
form and using an 'OnClick' instead - but couldn't get this working either.

Anyone have any suggestions on how to achieve what I want to do?

Thanks,

Terence
Jul 23 '05 #1
1 1985
On Tue, 17 Aug 2004 13:17:28 +0800, Terence Parker
<te*****@nospam .parker.hk> wrote:

[snip]
Anyone have any suggestions on how to achieve what I want to do?


I would suggest NOT trying what you want to do. You have server-side
capabilities, so use them.

Detect on the server whether the form is intended for submission or
preview. If it's the latter, produce a page similar to the editing page,
but with a section that contains a preview of the message. No needless
JavaScript dependency and no reliance on (possibly disabled) pop-ups.

JavaScript, and everything you can do with it, should be considered an
optional component. Relying on it can break a site.

By the way, you probably don't want to do this:

<textarea cols="55" rows="15" name="content"> </textarea>
<!-- .... -->
<input type="hidden" name="content" value="">

That is likely[1] to produce a collection of 'content' values, not one.

Mike
[1] I say "likely", because a user agent doesn't have to submit form
controls that have no value. However, some obviously will. I also don't
know if you alter the value with JavaScript.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail
Jul 23 '05 #2

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

Similar topics

3
17439
by: Joel | last post by:
Hi there, My original window (A) opens a modal dialog window (B). In B, you fill out a form and submit it to itself for processing. When B reloads, it knows that is successfully processed the form and it suppose to close itself after returning "1" or "0" to A. My problem is that B will never close. When I submit it, it kind of opens a new window and close that one before
1
14145
by: Paul Oakfleet | last post by:
The script below will disable Submit button until user accept terms, and will redirect user to another page after clicking on Submit button. The script seems to work fine on my PC (Windows XP, IE6), however I don't know if it's written well. I would like the opinion of someone who knows how to write these codes properly. Please let me know if there're any logic errors. PS: Please keep in mind that I didn't write this script, I found it
2
73363
by: Terence Parker | last post by:
How does one go about submitting a form with a link - but submitting it to a new window AND to a page different to that described within the action="" option of the <form> tag? Say, for example, I have a simple form such as the following: <form method="POST" action="submit.php" name="AForm"> Name: <input type="text" name="Name" length="20"><br> Age: 15 <a href="age.php">change age</a><br> <input type="submit" name="submit"...
2
4892
by: Margaret Werdermann | last post by:
Hi all: I'm having a nasty time with a particularly difficult piece of code and was hoping someone might be able to help me. I have a FormMail form that originally worked perfectly. Then, I had to add a JavaScript function to the Submit button to make a server function run when the form was submitted. Unfortunately, this JavaScript wouldn't run when the button was designated as a Submit, so I changed the button and placed a...
1
3424
by: Piotr | last post by:
I have popup window (window.open) where I put any value in input field. After submit I wan to to return to the main window and get value from popup window. How to close popup window and return to the main after submit?
3
2598
by: Arun K | last post by:
Hi, I am creating a simple .aspx page to add some fields with validation. I have used different .NET validations like REquiredFieldValidator, RegularExpressionValidator and showed the summary in the bulleted list on top. I have 3 text boxes, and two RadioButtonList. and 3 buttons. One for Submit, Reset and Exit. If submit is pressed page should be validated and submit (insert into
4
3500
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I click a button on a pop-up window the javascript for that button click does a 'button.form.submit'. On the Server side there is a Button click event for this button, but for some reason it no longer fires. It worked fine before and everything...
6
1976
by: vunet.us | last post by:
Hello, I have an html form which users fill out and submit. The form contains one textarea which I want them to preview before submitting. This, probably, means that there will be a link/button saying "Preview" and JS will open a new window and submit the form. The new window page will get value of one field and display it. I believe this is how it should be done. Is there a good way someone can recommend me how I can implement this or...
11
5289
by: V S Rawat | last post by:
using Javascript, I am opening a web-based url in a popup window. MyWin1=Window.Open(url, "mywindow") There is a form (form1) in the url in that popup window, I need to submit that form. How do I submit that form1 from the javascript from my current window? Thanks.
0
8802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8697
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8579
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7297
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2699
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 we have to send another system
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.