<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>