开发者

Printing(on paper) the values of html textboxes within a form

开发者_JS百科I have an html form with a large number of various textboxes containing data. I have a button the bottom of that page that says Print. Now I do not want to print the entire page. I want only the values of certain textboxes to be printed out on paper when that button is pressed.

Javascript is the route I was looking for...

Can someone just give me the basic code to print out the content of one box?

one example please

************EDIT****************

It appears as if my question was poorly worded. What I want to do is grab data from these html input text boxes and load it up on a new page after the print button is pressed and print that new page. I want to know how to grab that data from the boxes, and paste it on the popup page.


I'd do this with a print stylesheet.

You can hide the elements you don't want, rearrange them however you wish and style them all specifically for the printout.

@media print {
  /* style sheet for print goes here */
}

http://www.w3.org/TR/CSS2/media.html


You can acheive this with CSS using a print style sheet.

In the style sheet, just hide everything apart from the text boxes

* { display: none }

textarea { display: block }

See here for details http://www.webcredible.co.uk/user-friendly-resources/css/print-stylesheet.shtml


Add in your page header:

<link rel="stylesheet" href="view.css" media="screen"/>
<link rel="stylesheet" href="print.css" media="print"/>

Now keep your standard CSS in view.css. In print.css add styling to format/hide/show elements you want to see on paper.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜