he************@se.transport.bombardier.com (Henrik J?nsson) writes:
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
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'