Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form 3.3 | Q175 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.