物件導向的asp編程之六–用於自動顯示RecordSet的表格

來源:互聯網
上載者:User

<script language=jscript runat=server>
// ************************************************************************
// Script Compont Object Model
// Design for Active Server Pages
//
// Copyright 2003  Version 1.0
// Made by 尹曙光
// ************************************************************************

//用於顯示一個recordset中的資料,可以指定顏色和樣式

//介面函數
function createJDBList(){
  var objJDBlist=new JDBlist
  objJDBlist.create()
  return objJDBlist
}

//類體定義
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
}

//方法實現
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">沒有資料!<' + '/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>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.