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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hypothetical Question

Status
Not open for further replies.

DigitalBoy

Programmer
Oct 11, 2000
87
US
Hey gang,

I attempting to write code for a revved-up print button and I was wondering if what I want to do is possible. Here's the basic gist of it. I have an HTML table in my page template that contains the information that I want to have printed. I was thinking of:

1) Somehow storing that information in a variable.
2) Sending that variable to be printed.

What do you think? Is this possible?

Thanks,

- DB
Matt Torbin Designs

AIM: dgtlby
ICQ: 68300740
 
boohoohooo..

Nope. can't do that.

you could however open a popup window print inside it the variable in question you want to send to the printer.

However when you call window.print() a dialog box appears to ask the user to choose his printer settings he then has a choice to click ok or not. Gary Haran
 
Ok, take this page for example. Let's say that I wanted to create a print button that ONLY printed the purple postings and responses (NOT the sidebars). I'd have to do something like the following:

<script language=&quot;JavaScript&quot;>
<!--
function printMe() {
var cellData = document.[tableName].rows(0).cells(1).value;
alert(cellData);
}
//-->
</script>

Will this work? Matt Torbin Designs

AIM: dgtlby
ICQ: 68300740
 
Well, if I can open a popUp window, then I can do what I want without the use of the popUp. I simply have to send the variable to the right function... right? Matt Torbin Designs

AIM: dgtlby
ICQ: 68300740
 
fact of the matter is that sending stuff to the printer with javascript needs the confirmation of the user.

Otherwise I would be printing all kinds of stuff on peoples computer everywhere.

See the security concern why JavaScript is not meant to do this? Gary Haran
 
No, I completely understand that and I'm OK with that. This code for an Intranet site, so I can control more of what is going on (I probably should have told you that from the get-go).

How would I go about doing this? Matt Torbin Designs

AIM: dgtlby
ICQ: 68300740
 
You can either have the browser print the whole page, or none of the page. Javascript isn't doing the printing request, the browser is. Javascript only accesses the print-the-whole-page function built into the browser. So, like xutopia said, if you only want to print certain information from a page, you have to write just that info to another page and print that one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top