Using ASP to print output on the browser

Source: Internet
Author: User
Tags microsoft frontpage

Use ASP to combine JavaScript or VBScript to generate a dynamic Web page. When this method is used in practical applications, it is unavoidable to print out the results. We can also sort out the results of the query and print the output directly using the print buttons on the browser toolbar. The following program is to access the sales table from the database pubs in SQL Server, with VBScript on both the server and the workstation side. Navigator access is available when the workstation side uses JavaScript.

〈html〉〈head〉

〈meta http-equiv=″content-type″content=″text/html; charset=gb-2312-80″〉

〈meta name=″vi60-defaultclientscript″content=″vbscript″〉

〈meta name=″generator″content=″microsoft FrontPage 3.0″〉

〈title〉sales〈/title〉〈/head〉

〈body〉〈form〉

〈table border=″0″width=″800″cellspacing=″0″cellpadding=″0″〉

The definition of the table width 800 points

〈tr〉〈td〉〈div align=″center″〉〈center〉〈h2〉〈strong〉 Order Report 〈/strong〉〈/h2〉

〈/center〉〈/div〉〈/td〉〈/tr〉〈tr〉〈td〉〈div align=″right″〉〈p〉 Unit: Yuan 〈/td〉〈/tr〉〈/table〉

〈table border=″1″width=″800″cellspacing=″0″cellpadding=″0″〉〈tr〉

〈TD width=″25%″align=″center″〉stor_id

〈/TD〉〈TD width=″25%″align=″center″〉ord_num〈/td〉

〈TD WIDTH=″25%″ALIGN=″CENTER″〉ORD_DATE〈/TD〉〈TD width=″25%″align=″center″〉qty〈/td〉〈/tr〉〈% Set cn= Server.CreateObject (″adodb.connection″)

The definition of an ADO Connection object

Cn.open″provider=sqloledb;data source=202.203.208.1;initial Catalog=pubs;user id=sa;password=; ″

To define a database connection

Sql=″select Stor_id,ord_num,ord_date,qty from sales where Ord_date〉′1994-5-1′″

Set Rs=cn.execute (SQL)

While not rs.eof

Is the last record of the decision?

Qtyv=rs (″qty″)

sumqtyv=sumqtyv+qtyv%〉

〈tr〉〈td〉〈%=rs (″stor_id″)%〉〈/td〉

〈td〉〈%=rs (″ord_num″)%〉〈/td〉

〈td〉〈%=rs (″ord_date″)%〉〈/td〉

〈td〉〈%=qtyv%〉〈/td〉〈/tr〉

〈%rs.movenext′ move to the next record wend%〉〈tr〉

〈TD colspan=″3″〉 Total 〈/td〉

〈td〉〈%=sumqtyv%〉〈/td〉

〈/tr〉〈/table〉〈%cn.close%〉〈/form〉〈/body〉〈/html〉

To ensure that you can print reports of various sizes, you can first set the paper size for the print settings in the browser to the widest, and then output different report sizes by adjusting the value of the 〈table width=″″〉.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.