Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing the entire textarea

Status
Not open for further replies.

SKTodd

Programmer
Mar 11, 2002
33
US
I am trying to print the full content of a text area not just the 1 row specified on the input form. I am trying to do so by moving the textarea to a DIV which is hidden on the input but displayed when printing. See my sample code. Any ideas why it doesn't work? Any suggestions on how to accomplish the end result using a better method?
<HTML>
<HEAD>
<STYLE type=&quot;text/css&quot; media=&quot;print&quot;>
DIV.div1 {
DISPLAY: none }
DIV.div2 {
FONT-FAMILY: Arial, Verdana, sans-serif;
FONT-SIZE: 11px;
FONT-WEIGHT: bold;
BORDER: none;
WIDTH: 100% }
</STYLE>
<STYLE type=&quot;text/css&quot;>
TEXTAREA.textareastyle {
WIDTH: 100%;
FONT-FAMILY: Arial, Verdana, sans-serif;
FONT-SIZE: 11px;
FONT-WEIGHT: bold;
BORDER: none;
COLOR: #0066CC }
DIV.div1 {
FONT-FAMILY: Arial, Verdana, sans-serif;
FONT-SIZE: 11px;
FONT-WEIGHT: bold;
BORDER: none;
WIDTH: 100% }
DIV.div2 {
display: none }
</STYLE>

<SCRIPT LANGUAGE=&quot;javascript&quot;>
<!--
function reformat_text() {
var old_reason = document.getElementById(&quot;reason&quot;);
form1.reason_full = old_reason; }
//-->
</SCRIPT>
</HEAD>

<BODY>
<FORM method=&quot;post&quot; action=&quot;&quot; name=&quot;form1&quot; ID=&quot;form1&quot;>
<TABLE>
<TR>
<TD>Reason for Request<BR>
<DIV class=&quot;div1&quot;>
<TEXTAREA class=&quot;textareastyle&quot; name=&quot;reason&quot; id=&quot;reason&quot; cols=&quot;100%&quot; rows=&quot;1&quot;></TEXTAREA>
</DIV>
<DIV class=&quot;div2&quot; id=&quot;reason_full&quot; name=&quot;reason_full&quot;><P> </P></DIV>
</TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD align=&quot;center&quot;> <BR><BR>
<INPUT onClick=&quot;reformat_text(this.form); window.print()&quot; type=&quot;button&quot; value=&quot;Print&quot;>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
 
Change the function to the following:

<SCRIPT LANGUAGE=&quot;javascript&quot;>
<!--
function reformat_text() {
var old_reason = document.form1.reason.value;
reason_full.innerHTML = old_reason; }
//-->
</SCRIPT> Mighty :)
 
Still doesn't print! Thanks for trying to help.
 
Try putting some static text into the DIV:

<DIV class=&quot;div2&quot; id=&quot;reason_full&quot; name=&quot;reason_full&quot;><P> This is just some temporary text.</P></DIV>

Comment out the contents of the reformat_text function:


<SCRIPT LANGUAGE=&quot;javascript&quot;>
<!--
function reformat_text() {
// var old_reason = document.form1.reason.value;
// reason_full.innerHTML = old_reason;
}
//-->
</SCRIPT>

Then print the document. If you don't see your temporary text then the problem lies with your style sheets. If you do see the temporary text then the problem is with your function. Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top