473,385 Members | 1,461 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Printing a selected area using javascript or vbscript

Hi,

Is there a way i can just print a designated area out of the whole
asp(or html) page using javascript or vbscript.
i want to mark out the beginning and the end on the page and create a
link just to print out that section.
Please help me if there is any way to do this.

Thankyou
Jul 23 '05 #1
4 14434
Anshul Gupta wrote:
Is there a way i can just print a designated area out of the whole
asp(or html) page using javascript or vbscript.
i want to mark out the beginning and the end on the page and create a
link just to print out that section.
Please help me if there is any way to do this.


I think you are looking for a CSS profile:

<style media="print">
.onlyscreen
{
display: none;
}
</style>

AFAIK this works in IE5.0+.
Then you just assign the class, eg:

<p class="onlyscreen">This text displays on screen but will not be printed</p>

I also use this (IE5.0+?) trick to dynamically change class names:

<p onClick="thisid.className='otherclass';" id="thisid">text here</p>

Hope this helps
Bart
Jul 23 '05 #2
Hi,

thankyou for the solution, i tried it and it works fine.
but i have to modify this a little....

i generate like 300 different tables on my asp page, now what i want
is a button or a link on top of every table which says 'Print this
page' and when a user clicks on any one of these links then only that
page (or table) should get printed and nothing else.

could you please help me in doing that.
Thankyou
Regards

Anshul Gupta
ba**@nijlen.com (Bart Van der Donck) wrote in message news:<b5**************************@posting.google. com>...
Anshul Gupta wrote:
Is there a way i can just print a designated area out of the whole
asp(or html) page using javascript or vbscript.
i want to mark out the beginning and the end on the page and create a
link just to print out that section.
Please help me if there is any way to do this.


I think you are looking for a CSS profile:

<style media="print">
.onlyscreen
{
display: none;
}
</style>

AFAIK this works in IE5.0+.
Then you just assign the class, eg:

<p class="onlyscreen">This text displays on screen but will not be printed</p>

I also use this (IE5.0+?) trick to dynamically change class names:

<p onClick="thisid.className='otherclass';" id="thisid">text here</p>

Hope this helps
Bart

Jul 23 '05 #3
gu*****@iit.edu (Anshul Gupta) wrote:
thankyou for the solution, i tried it and it works fine.
but i have to modify this a little....
i generate like 300 different tables on my asp page, now what i want
is a button or a link on top of every table which says 'Print this
page' and when a user clicks on any one of these links then only that
page (or table) should get printed and nothing else.
The code underneath should help you. Not sure about browser memory
issues if you plan to use that for 300 tables -> you need to test
that. Or you can split up the ASP pages so that less than 300 tables
are shown per page.

<html>
<head>
<style media="print">
..onlyscreen
{
display: none;
}
..printerandscreen
{
display: block;
}
</style>
<script language="javascript">
function reset_classes()
{
t1.className='onlyscreen';
t2.className='onlyscreen';
t3.className='onlyscreen';
}
</script>
</head>
<body>

<table border=1 id=t1 class=onlyscreen>
<tr>
<td><input
type=button
value=print
onClick="reset_classes();
t1.className='printerandscreen';
window.print();" Content Table 1 </td>
</tr>
</table>

<table border=1 id=t2 class=onlyscreen>
<tr>
<td><input
type=button
value=print
onClick="reset_classes();
t2.className='printerandscreen';
window.print();" Content Table 2 </td>
</tr>
</table>

<table border=1 id=t3 class=onlyscreen>
<tr>
<td><input
type=button
value=print
onClick="reset_classes();
t3.className='printerandscreen';
window.print();" Content Table 3

</td>
</tr>
</table>

</body>
</html>

----
Bart
Jul 23 '05 #4
I have a similar problem I'm trying to solve. I have a page with a
list of items. when one clicks an item in the list a pop-up window
appears with more info about that item. the pop-up is using layers and
'visible'/'hidden' to display the additional info. the add. info is
located on the same page as the list but is hidden until the user
clicks the link. the add. info is contained in <span> tags with an
"id" for each different item.

when a visitor prints the page while the extra info is showing they
get the new info overprinted on top of the original list.

what i think i should be doing is providing a "print this" javascript
link inside my <span> tags that somehow references the "id" of that
span (thisid?), but I don't know how to do this.

the idea is that using the normal print method will give the user a
printout of the orginal list and using the "print this" js link will
just print the additional info box. does this make sense? TIA
ba**@nijlen.com (Bart Van der Donck) wrote in message news:<b5**************************@posting.google. com>...
Anshul Gupta wrote:
Is there a way i can just print a designated area out of the whole
asp(or html) page using javascript or vbscript.
i want to mark out the beginning and the end on the page and create a
link just to print out that section.
Please help me if there is any way to do this.


I think you are looking for a CSS profile:

<style media="print">
.onlyscreen
{
display: none;
}
</style>

AFAIK this works in IE5.0+.
Then you just assign the class, eg:

<p class="onlyscreen">This text displays on screen but will not be printed</p>

I also use this (IE5.0+?) trick to dynamically change class names:

<p onClick="thisid.className='otherclass';" id="thisid">text here</p>

Hope this helps
Bart

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jody Gelowitz | last post by:
I am having a problem with printing selected pages. Actually, the problem isn't with printing selected pages as it is more to do with having blank pages print for those pages that have not been...
7
by: NewbieJon | last post by:
I am attempting to send the variable "sComputerName" from my ActiveX script to "GetInfo.asp" using javascript. (Having been advised this is the way to get my ActiveX variable into my ASP script) ...
3
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
7
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of...
6
by: SRafiq | last post by:
Hi I need help with a topic I have an html page and in it i have a textarea which can have a multiple of info, is there any possible way that i can out put a specific area of the textarea using...
1
by: Roy X | last post by:
Hello - I am trying to embed JavaScript to an ASP page which will be executed on the server side and will send a HTTP request from the ASP Web server another remote server. Then I need to...
1
by: anniefs | last post by:
hi help me i m so much stuck int he code and i have no time .... i used ASP VBscipt and javascript functions with MS database javascript function add records in MS DB by using ASP vbscript...
1
by: mikegolden | last post by:
An application I'm working on makes extensive use of output parameters and return values, thus forcing me to use the ADODB Command object to execute the stored procs. For recordset returning stored...
4
by: pghantasala | last post by:
How to get available physical memory using javascript NOT USING WMI ?? any other way? I need to achieve this by using javascript/vbscript and I cannot use WMI. Please let me know the possibilities.
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.