Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q175 How can I write the contents of a textarea to another frame whilst retaining the line breaks?

You are here: irt.org | FAQ | JavaScript | Form | 3.3 | Q175 [ previous next ]

With the simple addition of the <PRE> and </PRE> tags:

frame.html:

<FRAMESET COLS="50%,*">
<FRAME SRC="linebreaks.html">
<FRAME SRC="dummy.html" NAME="otherframe">
</FRAMESET>

dummy.html:

<H1>dummy.html</H1>

linebreaks.html:

<SCRIPT LANGUAGE="JavaScript"><!--
function process() {
    alert(document.myform.mytext.value);
    parent.otherframe.document.writeln('<PRE>' + document.myform.mytext.value + '<\/PRE>');
}
//--></SCRIPT>

<FORM NAME="myform">
<TEXTAREA NAME="mytext" COLS="30" ROWS="10">
This
is
a
test.
</TEXTAREA>
<INPUT TYPE="BUTTON" VALUE="OK" onClick="process()">
</FORM>

©2018 Martin Webb