473,408 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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="JavaScript" type="text/javascript">
function submitForm(t) {
window.open("", t, "width=500,height=450");
return true
}
</SCRIPT>
<form action="user_message.php" method="POST" name="UserMessage">
<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="return 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.Preview.content.value =
document.form.UserMessage.content.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 1963
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
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...
1
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,...
2
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,...
2
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...
1
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...
3
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...
4
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...
6
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...
11
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. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...

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.