PDA

View Full Version : Print Textarea


kathryn
04-25-2003, 04:08 PM
Hi,
I have a <textarea> tag on my web page with info inside that contains legal terms and conditions. Is there any way to allow the customer to print this info?

Thanks, Kathryn

x_goose_x
04-25-2003, 04:51 PM
You can try making a popup, then printing that. Haven't tested it, but might want to try:


<script language="JavaScript1.2" type="text/javascript">

function print_txt (what) {
pop = window.open();
pop.document.write("<pre>"+what+"</pre>");
pop.document.print();
//pop.close(); //closes window afterwards
}

</script>

<form>
<textarea cols="20" rows="20" name="txt"></textarea>
<input type="button" value="print" onclick="print_txt(this.form.txt.innerTEXT);">
</form>

beetle
04-25-2003, 04:55 PM
this.form.txt.innerTEXT ??

Wouldn't the more proper

this.form.txt.value

Be better?

Oh, and I think you want

pop.document.close();

Just before

pop.print();


LIke you said, not tested :)

cheesebagpipe
04-25-2003, 05:00 PM
Why not CSS media types?

http://www.evolt.org/article/Kissing_Print_Versions_of_Pages_Goodbye/20/22225/

I've used a hidden iframe....

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="javascript">

function dump_and_print(oTextarea) {
var pf = frames['printfrm'];
pf.document.open();
pf.document.write('<html></head></head><body style="margin:0px;"><form><textarea rows="8" cols="48" wrap="virtual">');
pf.document.write(oTextarea.value);
pf.document.write('</textarea></form></body></html>');
pf.document.close();
pf.focus();
pf.print();
}

</script>
</head>
<body>
<iframe name="printfrm" id="printfrm" style="width:0px;height:0px;"></iframe>
<form>
<textarea name="output" rows="8" cols="48" wrap="virtual">yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda--yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-
yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-
yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda-yadda</textarea><br>
<input type="Button" value="Print yaddas" onclick="dump_and_print(output)">
</form>
</body>
</html>

kathryn
04-28-2003, 08:46 AM
Hi,
The first solution when the textarea info appears in a new window would work if i could keep it in the background so the user never sees it and it closes after printing.

The second option where the entire text area is printed is better but only the first page of text prints out??
I have quite a lot of info in the text area any way to print out on multiple pages??

Thanks, Kathryn

swmr
05-03-2003, 08:18 PM
I have quite a lot of info in the text area any way to print out on multiple pages??

Something about that issue is mentioned on this (http://msdn.microsoft.com/library/en-us/dnwebteam/html/webteam04022001.asp) page, under the heading:

Getting Cut Short in Internet Explorer 5.5?