Q: Printing a selection (kind of)

H

Henrik J?nsson

Hi!

I have a problem that I can't find a solution to.

I have a perl script that generates reports from our NCR system for
our intranet. The NCRs are displayed on a single html page. Now I
would like to have a print button next to each NCR so that the users
can press the print button and only the nearest NCR is printed.

The problem is how can I select a single NCR in the page. I can search
for a beginning and end pattern but I don't have a clue how to select
the text in javascript.

Any idea?

Regards

Henrik Jönsson
 
L

Lasse Reichstein Nielsen

I have a perl script that generates reports from our NCR system for
our intranet. The NCRs are displayed on a single html page. Now I
would like to have a print button next to each NCR so that the users
can press the print button and only the nearest NCR is printed.

I have no idea what "NCR" means, so the answer will be general.

The method I would use, is to have a special stylesheet for
media="print" and let all but one of the "NCR"'s have a class that
makes them disappear (display:none). When clicking the print button,
the appropriate NCR is set to a different class that is visible, and
then the page is printed.

Example: <URL:http://www.infimum.dk/privat/selectivePrint.html>

To see it work without spending a stack of paper, just click on one of
the "print" buttons, cancel the printing, and look at the print
preview.
The problem is how can I select a single NCR in the page. I can search
for a beginning and end pattern but I don't have a clue how to select
the text in javascript.

If you control the Perl script, then you can just wrap each NCR in a
div element with a unique id, and let the print button find the
element using document.getElementById("uniqueId42"). I am lazy, so in
the example, I just put the button inside the div and used parentNode.

If you don't have a single block surrounding the NCRs, and for some
reason is not allowed to change that, then you will have to find another
way to affect the elements. It is most likely much harder.

/L
 
H

Henrik J?nsson

Thanks!

Exactly what I needed. BTW, NCR stands for a non conformity report,
aka change request, defect report etc.

/henrik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top