Click to See Complete Forum and Search --> : Need help printing form textarea


zasu
06-02-2003, 09:16 AM
I'm sure that this issue has been covered in great detail before, but I was wondering if someone could help me with a Java script design to print a form field from a Web page. Currently, my print function delivers only the visible portion of the form but I would like to permit my readers to printout the Web content in its entirety. My script is in three parts. One is in the head of the document, and it sets up the variable.

<script language="JavaScript">
var isReady = false;
function doPrint(){
if (document.execCommand){
if (isReady){document.execCommand("Print");}
}else{
alert('Feature available only in Internet Exlorer 4.0 and later.');
}
}
</script>

The next portion is in the body of the HTML and states the variable "isReady" to be "true"

<body onload="isReady=true" bgcolor="#ff0000" text="#990000">

The final portion is at the bottom of the form and it is the submit button, which executes the script.

<input name="button" type=button onClick="javascript:this.form.textarea.focus();this.form.textarea.select();doPrint();" value="Print">

The textarea is the important part of the form, which I would like to have printed in its entirely. You can see this script in action (behaving badly) at:


This and That Page (http://www.pass.to/tgmegillah/print3thisnthat.asp)

As you can see from the Web page, the form is just a couple of identifying fields (date, title etc) with the bulk of the space devoted to the textarea. The textarea is a scroll box limited to ten lines for layout purposes, but the documents vary in length.

I hope someone will be able to suggest what's missing so that the selected text in the textarea can be printed in its entirety.

Thank you in advance for any and all assistance.

ZaSu

havik
06-02-2003, 10:55 AM
How about creating a printer friendly version?

Havik

zasu
06-02-2003, 11:43 PM
I currently have duplicate pages designed for Web TV, which are printer-friendly. I was hoping to keep better browsers away from these pages since the navigation on them leads to other low-tech Web TV capable pages.

I was hoping to design a Java script that would function on all of my higher tech pages, but this script merely succeeds in highlighting the entire text area, while only printing the visible portion. Perhaps a series of commands which would create a temporary window with the full text, and then send the temp page to the printer would do the trick.

Do you have any suggestions in this direction?

Thanks again for your quick response, Havik, and I hope that script savvier minds than mine can devise a solution.

ZaSu