T
Terence Parker
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
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