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
<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