Object-oriented ASP programming 6-used to automatically display recordset tables

Source: Internet
Author: User

<Script language = JScript runat = Server>
//************************************** **********************************
// Script compont Object Model
// Design for Active Server Pages
//
// Copyright 2003 version 1.0
// Made by Yin Shuguang
//************************************** **********************************

// Display the data in a recordset. You can specify the color and style.

// Interface function
Function createjdblist (){
VaR objjdblist = new jdblist
Objjdblist. Create ()
Return objjdblist
}

// Class definition
Function jdblist (){
 
This. adorecordset

This. Width
This. Border
This. cellspacing
This. cellpadding
This. Class

This. titleclass

This. firstcolor
This. secondcolor

This. Create = _ jdblist_create
This. Display = _ jdblist_display
}

// Method implementation
Function _ jdblist_create (){

This. adorecordset = ""

This. width = "100%"
This. Border = "1"
This. cellspacing = "0"
This. cellpadding = "1"
This. Class = ""

This. titleclass =''

This. firstcolor =''
This. secondcolor =''

}
Function _ jdblist_display (){
VaR htmldso = '';
VaR nfields = This. adorecordset. Fields. count;
If (nfields)
{
VaR n = 0;
Htmldso + = '<' + 'table width = "'+ this. width + '"id ="' + this. ID + '"cellspacing ="' + this. cellspacing + '"cellpadding ="' + this. cellpadding + '"border ="' + this. border + '"class ="' + this. class + '">/N ';

Htmldso + = '<' + 'tr> ';
For (VAR I = 0; I <nfields; I ++)
{
Htmldso + = '<' + 'td class = "'+ this. titleclass + '">' + this. adorecordset (I ). name + '<' + '/TD> ';
}
Htmldso + = '<' + '/tr>/N ';

If (! (This. adorecordset. EOF & this. adorecordset. bof ))
This. adorecordset. movefirst ()
Else
Htmldso + = '<' + 'td colspan = "'+ nfields +'" align = "center"> no data! <'+'/TD>'

VaR RCC = 0
While (! This. adorecordset. EOF)
{// Add each record to table
If (RCC % 2 = 0)
Htmldso + = '<' + 'tr bgcolor = "'+ this. firstcolor +'"> ';
Else
Htmldso + = '<' + 'tr bgcolor = "'+ this. secondcolor +'"> ';

For (VAR I = 0; I <nfields; I ++)
{
Htmldso + = '<' + 'td> '+ this. adorecordset (I). Value +' <'+'/TD> ';
}

Htmldso + = '<' + '/tr>/N ';

This. adorecordset. movenext ();

RCC ++
}
Htmldso + = '<' + '/table> ';
}
Response. Write (htmldso );
}
</SCRIPT>

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.