By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,997 Members | 1,470 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,997 IT Pros & Developers. It's quick & easy.

Q: Printing a selection (kind of)

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.'
Jul 20 '05 #2

P: n/a
Thanks!

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

/henrik
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.