/************* layer function ******************/
function makeLayer( idStr ) {
this.idStr = idStr;
if(bw.ns4)this.obj=document.layers[idStr];
else if (bw.ns6) this.obj = document.getElementById(idStr);
else this.obj=eval('document.all.'+idStr);
if (bw.ns6) this.css=this.obj.style;
else if (bw.ns) this.css=this.obj;
else this.css=this.obj.style;
this.x = getLayerX(this.idStr);
this.y = getLayerY(this.idStr);
this.moveTo=lib_moveTo;
return (this);
}
function lib_moveTo(x,y){
    this.x=x!=''?x:this.x;
this.y=y!=''?y:this.y;
this.css.left=this.x;
this.css.top=this.y
}
function getLayerX( ID ) {
   if (bw.ns6) return(parseInt(document.getElementById(ID).style.left));
   else if (bw.ns) return(document.layers[ID].left);
   else return(document.all[ID].offsetLeft);
}
function getLayerY( ID ) {
if (bw.ns6) return(parseInt(document.getElementById(ID).style.top));
else if (bw.ns) return(document.layers[ID].top);
else return(document.all[ID].offsetTop);
}
//-->
</SCRIPT>
</HEAD><BODY onload="dragInit()">
<SCRIPT LANGUAGE="JavaScript">
<!--//注意不要把顺序颠倒
oExcel=new TExcel('oExcel');
with(oExcel){
   addField('职级','描述','ffgg','efew','egwg','人','合共工资','俭这%');//用于创建字段
   addRecord('llrock','llrock','i love you i love you ')//用于创建纪录
   addRecord('llrock','llrock','i love you i love you ')
   addRecord('llrock','llrock','i love you i love you ')
   addRecord('llrock','llrock','i love you i love you ')
   addRecord('llrock','llrock','i love you i love you ')   makeStyle();
   makeCode();
   document.write(htmlcode);
   getObj();
   arrange();
}
//-->
</SCRIPT>
</BODY>
</HTML>
昨天有个人要能够拖懂td的东西,做了好久,结果发现用table做太难了,td的width和height太难控制,结果想了想就用div做了,发现听想table的,不信你看看,hehe,昨天失恋放分,今天就放代码,其实这个东西没什么用,不过代替table 倒也不错,或者在结些函数让她一次性提交大量数据到database,hehe

解决方案 »

  1.   

    <style>
    .tabletitle {
    font: icon;
    color: buttontext;
    background: threedhighlight;
    border-top:1px solid #000000;
    border-right: 1px solid #000000;
    border-left-style: solid;
    border-bottom-style: none;
    border-left-width: 1px;
    border-left-color: #000000;
    table-layout: fixed;
    }.tabletitleTD {
    background: #0099FF;
    overflow:hidden;
    height:15;
    border-left:1px solid buttonhighlight;
    border-right:1px solid buttonshadow;
    border-top:1px solid buttonhighlight;
    border-bottom:1px solid buttonshadow;
    color: #FFFFFF;
    }
    .tableAct {
    background: #FFFFFF;
    font: icon;
    color: buttontext;
    border-right: 1px solid threedshadow;
    }
    .tableAct TD{
    border-left: 1px solid buttonshadow;
    }
    .tdwbar{
    cursor:w-resize;
    background:buttonface;
    behavior:url(dragline.htc);
    }
    .tt {
    background-color: #FFFFFF;
    border-top: 1px none #666666;
    border-right: 1px none #666666;
    border-bottom: 1px solid #666666;
    border-left: 1px none #666666;
    white-space: nowrap;
    word-break:break-all;
    }
    </style>
    <TABLE  border="0" cellPadding="0" cellSpacing="0"  class="tabletitle" id="tb1">
      <TR> 
        <TD width="100" class="tabletitleTD" >标题1</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="100" class="tabletitleTD" >标题2</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="200" class="tabletitleTD" >标题3</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="50" class="tabletitleTD" >标题4</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="200"  bgcolor="#0099FF" class="tabletitleTD" >rerewr</TD>
    <!--   <td width="150" height="9" align="center" class="tabletitleTD" >职级</td>
                <td width="1" rowspan="2"  class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" >描述</td>
                <td width="1" rowspan="2" class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d3 >人头总数</td>
                <td width="1" rowspan="2" class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d4>合共工资</td>
                <td width="1" rowspan="2"class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d5>涨幅 %</td>-->
      </TR>
      <TR> 
        <TD class="tt">123</TD>
        <TD width="100" class="tt">123</TD>
        <TD width="200" class="tt" >3463464reyhdytwru868w568</TD>
        <TD width="50" class="tt">66</TD>
        <TD width="200"   class="tt">88</TD>
      </TR>
      <TR> 
        <TD height="20" class="tt">123</TD>
        <TD width="100" class="tt">111</TD>
        <TD width="200" class="tt">44</TD>
        <TD width="50" class="tt">77</TD>
        <TD width="200"   class="tt">iiii</TD>
      </TR>
      <TR> 
        <TD class="tt">46</TD>
        <TD width="100" class="tt">5645</TD>
        <TD width="200" class="tt">757</TD>
        <TD width="50" class="tt">757</TD>
        <TD width="200"   class="tt">456</TD>
      </TR>
    </TABLE>
    这个可以让行字自动折行,但我不知它为什么拉开的时候只能到原使初定列宽。而乘下的就不能跳回一行。请指教。
      

  2.   

    我觉得只用一个Table比较好控制,所以就改了一下。还有一个可以在拖动每列时,让表格自动申展,但就是有还有点不灵活,请看这。而且易出错。我想知道让上面的功能还这个功能一起结合的方法。能有吗。
    <style>
    .tabletitle {
    font: icon;
    color: buttontext;
    background: threedhighlight;
    border-top:1px solid #000000;
    border-right: 1px solid #000000;
    border-left-style: solid;
    border-bottom-style: none;
    border-left-width: 1px;
    border-left-color: #000000;

    }.tabletitleTD {
    background: #0099FF;
    overflow:hidden;
    height:15;
    border-left:1px solid buttonhighlight;
    border-right:1px solid buttonshadow;
    border-top:1px solid buttonhighlight;
    border-bottom:1px solid buttonshadow;
    color: #FFFFFF;
    }
    .tableAct {
    background: #FFFFFF;
    font: icon;
    color: buttontext;
    border-right: 1px solid threedshadow;
    }
    .tableAct TD{
    border-left: 1px solid buttonshadow;
    }
    .tdwbar{
    cursor:w-resize;
    background:buttonface;
    behavior:url(dragline.htc);
    }
    .tt {
    background-color: #FFFFFF;
    border-top: 1px none #666666;
    border-right: 1px none #666666;
    border-bottom: 1px solid #666666;
    border-left: 1px none #666666;
    white-space: nowrap;
    }
    </style>
    <TABLE  border="0" cellPadding="0" cellSpacing="0"  class="tabletitle" id="tb1">
      <TR> 
        <TD width="100" class="tabletitleTD" >标题1</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="100" class="tabletitleTD" >标题2</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="200" class="tabletitleTD" >标题3</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="50" class="tabletitleTD" >标题4</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="200"  bgcolor="#0099FF" class="tabletitleTD" >rerewr</TD>
    <!--   <td width="150" height="9" align="center" class="tabletitleTD" >职级</td>
                <td width="1" rowspan="2"  class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" >描述</td>
                <td width="1" rowspan="2" class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d3 >人头总数</td>
                <td width="1" rowspan="2" class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d4>合共工资</td>
                <td width="1" rowspan="2"class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d5>涨幅 %</td>-->
      </TR>
      <TR> 
        <TD class="tt">123</TD>
        <TD width="100" class="tt">123</TD>
        <TD width="200" class="tt" >3463464reyhdytwru868w568</TD>
        <TD width="50" class="tt">66</TD>
        <TD width="200"   class="tt">88</TD>
      </TR>
      <TR> 
        <TD height="20" class="tt">123</TD>
        <TD width="100" class="tt">111</TD>
        <TD width="200" class="tt">44</TD>
        <TD width="50" class="tt">77</TD>
        <TD width="200"   class="tt">iiii</TD>
      </TR>
      <TR> 
        <TD class="tt">46</TD>
        <TD width="100" class="tt">5645</TD>
        <TD width="200" class="tt">757</TD>
        <TD width="50" class="tt">757</TD>
        <TD width="200"   class="tt">456</TD>
      </TR>
    </TABLE>
      

  3.   

    最开始我用table做的那个,就是你的那个贴子,同样很难控制,主要是table列宽之间会自动调整,所以后来我放弃了用table就有了这个!
    我理解你的意思:你希望想excel那样列宽可以任意大是吗?
    好吧,我就把它做成excel,晚上来这里取代码!
    事实上table比div速度慢,虽然table有更多的样式,这也可以模仿,除了点划线边框很难模访(可以结合图片),
      

  4.   

    是的,但是如果只在一个表格里控制就好多了,如果你用DIV做的话,引入数据库的变量是很不好做的(比如用别的语言引如界面输出变量),而且页面调整也比较困难。不知table是否能做出那种效果,如果不能自动最后一格向外申展可以稍后考虑。
      

  5.   

    先给你这个
    <style>
    .tabletitle {
    font: icon;
    color: buttontext;
    background: threedhighlight;
    border-top:1px solid #000000;
    border-right: 1px solid #000000;
    border-left-style: solid;
    border-bottom-style: none;
    border-left-width: 1px;
    border-left-color: #000000;
    }
    .tabletitleTD {
    background: #0099FF;
    overflow:hidden;
    height:15;
    border-left:1px solid buttonhighlight;
    border-right:1px solid buttonshadow;
    border-top:1px solid buttonhighlight;
    border-bottom:1px solid buttonshadow;
    color: #FFFFFF;
    }
    .tableAct {
    background: #FFFFFF;
    font: icon;
    color: buttontext;
    border-right: 1px solid threedshadow;
    }
    .tableAct TD{
    border-left: 1px solid buttonshadow;
    }
    .tdwbar{
    cursor:w-resize;
    background:buttonface;
    behavior:url(dragline.htc);
    }
    .tt {
    background-color: #FFFFFF;
    border-top: 1px none #666666;
    border-right: 1px none #666666;
    border-bottom: 1px solid #666666;
    border-left: 1px none #666666;
    white-space: nowrap;
    }
    .myscroll{FONT-SIZE: 12px;SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF;SCROLLBAR-SHADOW-COLOR: #e1e1e1;SCROLLBAR-3DLIGHT-COLOR: #e1e1e1;SCROLLBAR-TRACK-COLOR: white;  SCROLLBAR-DARKSHADOW-COLOR: white; scrollbar-Base-Color: white; scrollbar-arrow-Color:}
    </style>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function TDrag(){
       this.x1=null;
       this.x2=null;
       this.obj=null;
       this.tableW=null;
       this.tdW=null;
       this.table=null;
       this.targetTD=null;
    }
    function check(){
       var ok=false;
       if(!oDrag.obj){ok=false;return ok}
    }
    function getTdSid(sid){
       var targetSID=sid-1;
       while(document.all[targetSID].tagName!='TD'){targetSID--}
       return targetSID
    }
    function mDown(){
        oDrag.obj=window.event.srcElement;
        if(oDrag.obj.tagName=='TD'&&oDrag.obj.rowSpan!=1){
        var targetSID=getTdSid(event.srcElement.sourceIndex);
            oDrag.targetTD=document.all[targetSID];
    oDrag.table=event.srcElement.parentElement.parentElement.parentElement;
        oDrag.tableW=table.clientWidth;
        oDrag.x1=event.x
    }else{
        oDrag.obj=null;
        return false
    }
    }
    function mMove(){
       if(!oDrag.obj)return false;
       try{
       if(window.event.x>=(MainBG.offsetLeft+MainBG.clientWidth))return false;
    oDrag.x2=event.x;
    var dW=oDrag.x2-oDrag.x1;
    oDrag.targetTD.style.width=oDrag.targetTD.clientWidth+dW
    //if(dW>=0)
    oDrag.table.style.width=dW+oDrag.tableW;//------------>!!!
    }
    catch(x){}
    }
    function mUp(){
       oDrag.obj=null;
    }
    function refresh(){
       var table=TableBG.children[0]
       TableBG.style.width=table.clientWidth;
       TableBG.style.height=table.clientHeight;
       MainBG.style.width=(TableBG.clientHright>=500)?500:TableBG.clientWidth;
       MainBG.style.height=(TableBG.clientHright>=500)?500:TableBG.clientHeight+16;//默认,高度超过500px使用滚动}
    function dragInit(){
           oDrag=new TDrag();
       document.onmousedown = mDown
       document.onmousemove = mMove
       document.onmouseup = mUp;
    }
    //-->
    </SCRIPT>
    <div id="MainBG" style="position:absolute; left:100px; top:180px;   z-index:1; ;border: 1px none #000000;overflow:auto;" class=myscroll>
     <div id="TableBG" style="position:absolute; left:0px; top:0px; width:500px; height:277px; z-index:2; border: 1px none #000000"> 
    <TABLE  border="0" cellPadding="0" cellSpacing="0"  class="tabletitle" id="tb1">
      <TR> 
        <TD width="100" class="tabletitleTD" ><div style="overflow:hidden">标题1</div></TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="100" class="tabletitleTD" ><div style="overflow:hidden">标题1</div></TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="200" class="tabletitleTD" ><div style="overflow:hidden">标题1</div></TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="50" class="tabletitleTD" ><div style="overflow:hidden">标题1</div></TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="200"  bgcolor="#0099FF" class="tabletitleTD" >rerewr</TD>
    <!--   <td width="150" height="9" align="center" class="tabletitleTD" >职级</td>
                <td width="1" rowspan="2"  class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" >描述</td>
                <td width="1" rowspan="2" class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d3 >人头总数</td>
                <td width="1" rowspan="2" class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d4>合共工资</td>
                <td width="1" rowspan="2"class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d5>涨幅 %</td>-->
      </TR>
      <TR> 
        <TD class="tt" style="overflow:hidden">标题1</TD>
        <TD width="100" class="tt">123</TD>
        <TD width="200" class="tt" >3463464reyhdytwru868w568</TD>
        <TD width="50" class="tt">66</TD>
        <TD width="200"   class="tt">88</TD>
      </TR>
      <TR> 
        <TD height="20" class="tt">123</TD>
        <TD width="100" class="tt">111</TD>
        <TD width="200" class="tt">44</TD>
        <TD width="50" class="tt">77</TD>
        <TD width="200"   class="tt">iiii</TD>
      </TR>
      <TR> 
        <TD class="tt">46</TD>
        <TD width="100" class="tt">5645</TD>
        <TD width="200" class="tt">757</TD>
        <TD width="50" class="tt">757</TD>
        <TD width="200"   class="tt">456</TD>
      </TR>
    </TABLE>  </div>
    </div><SCRIPT LANGUAGE="JavaScript">
    <!--
    dragInit()
    refresh()//-->
    </SCRIPT>
      

  6.   

    下午去看病,医生居然说我有鼻斗炎,我说这几天怎么老打喷嚏,不停的大。
    这是你要得用table的,table的真的很难控制,其实我说用div就是为了通过数据库传入数据,我觉的非常方便,因为所有的代码我都是由javascript动态生成的,所以可以任意改变,但是由于table结构复杂,用javascrit生成麻烦,所以我从来不用table。我不明白你的最后一格向外申展是什么意思,是不是就是table宽度变大,还是用scrollbar控制
      

  7.   

    我先吃饭,带会在贴一个由js生成的,看到的人帮着up一下,我连续发了三张贴子,不能发了
      

  8.   

    請問前輩書寫script有甚麼好的工具沒有?謝謝.很佩服前輩寫的那段JavaScript.
      

  9.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <style>
    .tabletitle {
    font: icon;
    color: buttontext;
    background: threedhighlight;
    border-top:1px solid #000000;
    border-right: 1px solid #000000;
    border-left-style: solid;
    border-bottom-style: none;
    border-left-width: 1px;
    border-left-color: #000000;
    }
    .tabletitleTD {
    background: #0099FF;
    overflow:hidden;
    height:15;
    border-left:1px solid buttonhighlight;
    border-right:1px solid buttonshadow;
    border-top:1px solid buttonhighlight;
    border-bottom:1px solid buttonshadow;
    color: #FFFFFF;
    }
    .tableAct {
    background: #FFFFFF;
    font: icon;
    color: buttontext;
    border-right: 1px solid threedshadow;
    }
    .tableAct TD{
    border-left: 1px solid buttonshadow;
    }
    .tdwbar{
    cursor:w-resize;
    background:buttonface;
    behavior:url(dragline.htc);
    }
    .tt {
    background-color: #FFFFFF;
    border-top: 1px none #666666;
    border-right: 1px none #666666;
    border-bottom: 1px solid #666666;
    border-left: 1px none #666666;
    white-space: nowrap;
    }
    .myscroll{FONT-SIZE: 12px;SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF;SCROLLBAR-SHADOW-COLOR: #e1e1e1;SCROLLBAR-3DLIGHT-COLOR: #e1e1e1;SCROLLBAR-TRACK-COLOR: white;  SCROLLBAR-DARKSHADOW-COLOR: white; scrollbar-Base-Color: white; scrollbar-arrow-Color:}
    </style>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function TTable(name){
        this.name=name;
    this.cols=new Array();
    this.rows=new Array();
    this.items=new Array();
    this.colcount=0;//实际是列输减一
    this.rowcount=0;
    this.data=new Array();
    //style
    this.width=100;//colum width
    this.bgc="#e7e7e7";
    this.fontfamily="tahoma,arial,helvetica";
        //method
    this.addData=addData;
    this.trimData=trimData;
    this.create=create;
    this.display=display;
    this.refresh=refresh;
    }
    function TItem(owner,name,data,rindex,cindex,width,bgc,ftc){
        this.owner=owner;
    this.name=name;
    this.data=data;
    this.rindex=rindex;
    this.cindex=cindex;
    this.width=width||owner.width;
    this.bgc=bgc||owner.bgc;
    this.htmlcode=!rindex?'\n<TD width="100" class="tabletitleTD" >'+data+'</TD>\n<TD width="2" rowspan="'+owner.colcount+'" class="tdwbar" ></TD>':'\n<TD class="tt">'+data+'</TD>';
    }function addData(){
        var arg=addData.arguments;
        var len=arg.length;
    this.colcount=Math.max(this.colcount,len);
        var tmpdata=new Array();
    for(i=0;i<this.colcount;i++){
        tmpdata[i]=!arg[i]?'':arg[i];
    }
    this.data[this.data.length]=tmpdata;
    }
    function trimData(){
        for(i=0;i<this.data.length;i++){
        for(j=0;j<this.colcount;j++){
        this.data[i][j]=!this.data[i][j]?'&nbsp;':this.data[i][j];
    }
    }
    }
    function create(){
        for(i=0;i<this.data.length;i++){
        this.items[i]=new Array;
    for(j=0;j<this.colcount;j++){
        this.items[i][j]=new TItem(this,this.data[i][j],this.data[i][j],i,j)
    }
        }
    }
    function display(){
        this.htmlcode='';
    this.htmlcode+='\n<div id="MainBG" style="position:absolute; left:100px; top:180px; z-index:1; ;border: 1px none #000000;overflow:auto;" class=myscroll>'
                         +'\n<div id="TableBG" style="position:absolute; left:0px; top:0px; z-index:2; border: 1px none #000000">'
     +'\n<TABLE  border="0" cellPadding="0" cellSpacing="0"  class="tabletitle" id="tb1">'; for(i=0;i<this.data.length;i++){
        this.htmlcode+='\n<tr>';
        for(j=0;j<this.colcount;j++){
       this.htmlcode+=this.items[i][j].htmlcode;
    }
    this.htmlcode+='\n</tr>';
        }
    this.htmlcode+='</table></div></div>';
    // alert(this.htmlcode)
    document.write(this.htmlcode)
    }
    /*******************  drag function  ************************/
    function TDrag(){
       this.x1=null;
       this.x2=null;
       this.obj=null;
       this.tableW=null;
       this.tdW=null;
       this.table=null;
       this.targetTD=null;
    }
    function getTdSid(sid){
       var targetSID=sid-1;
       while(document.all[targetSID].tagName!='TD'){targetSID--}
       return targetSID
    }
    function mDown(){
        oDrag.obj=window.event.srcElement;
        if(oDrag.obj.tagName=='TD'&&oDrag.obj.rowSpan!=1){
         document.body.style.cursor="e-resize";
        var targetSID=getTdSid(event.srcElement.sourceIndex);
            oDrag.targetTD=document.all[targetSID];
    oDrag.table=event.srcElement.parentElement.parentElement.parentElement;
        oDrag.tableW=table.clientWidth;
        oDrag.x1=event.x
    }else{
        oDrag.obj=null;
        return false
    }
    }
    function mMove(){
       if(!oDrag.obj)return false;
       try{
       if(window.event.x>=(MainBG.offsetLeft+MainBG.clientWidth))return false;
    oDrag.x2=event.x;
    var dW=oDrag.x2-oDrag.x1;
    oDrag.targetTD.style.width=oDrag.targetTD.clientWidth+dW
    oDrag.table.style.width=dW+oDrag.tableW;//------------>!!!
    }
    catch(x){}
    }
    function mUp(){
      document.body.style.cursor="default";
      oDrag.obj=null;
    }
    function refresh(){
       table=TableBG.children[0]
       TableBG.style.width=table.clientWidth;
       TableBG.style.height=table.clientHeight;
       MainBG.style.width=(TableBG.clientHright>=500)?500:TableBG.clientWidth;
       MainBG.style.height=(TableBG.clientHright>=500)?500:TableBG.clientHeight+16;//默认,高度超过500px使用滚动
    }
    function dragInit(){
           oDrag=new TDrag();
       document.onmousedown = mDown
       document.onmousemove = mMove
       document.onmouseup = mUp;
    }
    //-->
    </SCRIPT>
    </HEAD><BODY onload="dragInit()"><SCRIPT LANGUAGE="JavaScript">
    <!--
    ot=new TTable();
    ot.addData('name','email','phoneCode','address','homepage','oicq')
    ot.addData('llrock','[email protected]','123456789','Beijing','user1.7host.com/ccrock','1234567')
    ot.addData(1,2,3,4)
    ot.addData(1,2,'',4,5,6)
    ot.addData(1,2,3,4,5)
    //ot.data=[[1,2,3,4],2,3]
    ot.trimData()
    ot.create()
    ot.display()
    ot.refresh()
    //-->
    </SCRIPT>
    </BODY>
    </HTML>
      

  10.   

    我习惯用上面这种方式来填加数据,这样只要从数据库得到一个二维树组,如
    a=[['name','email'],[1],[1,2,3]]然后直接复给ot.data=a就可以了,或者一行一行的来,把显示数据的任务交给客户端,我想你说的使用数据方便是通过服务器端如
    <%
      ...%>
      <table ...>
         <tr>
        <td>name</td><td>email</td><td>home</td>
          </tr> <% for i=1 to 10 %>
         <tr>
        <td><%rs("name")%></td>
         <td><%rs("email")%></td>
        <td><%rs("home")%></td>
        </tr>
    <% rs.movenext
       next%>
    但愿没有写错,我觉得这样写不是很好,祝你好运
      

  11.   

    TO:DreamMeng(划过月亮跨银河) 
    我接触js不过几个月,我们是同辈,呵呵,我一直都用editplus编辑代码,非常灵活,最开始用dw,后来发现她很笨拙,就从机器删掉了,editplus一级棒!
      

  12.   

    昨天网坏了,上不去,今天才上来,我说的Table可以申展,就是为了打印方便,你想想,要是一个table有些数看不着,不得把tabel扩大吗?那就不要求一页里面能看全了,还有<td>里的字换行问题,可以跟据<td>的宽度自由换行更可增加页面的美观性。要不我传入 的数很长的话它就有些不能显示出来了,比如其中一组数据每个<TD>里的数都很长,那就要table申展,而且<td>里的数也展开来。 editplus在哪有下载?我一直也是用dw
      

  13.   

    要不TABLE可以动态拉申,要不<TD>可以动态换行,看来只能退一步了,不知是否有好的办法。随便说一句,做程序员的,失恋是很平常的事,请你不要放在心上,呵呵……天涯何处无芳草,何要单恋那棵草。
      

  14.   

    呵呵,按你的说法table变宽,如果达到了窗口大小还没有完全先是数据怎么版,让td的高度自动变化更合适,在td的style="word-break:break-all"
      

  15.   

    请试试这段代码
    <style>
    .tabletitle {
    font: icon;
    color: buttontext;
    background: threedhighlight;
    border-top:1px solid #000000;
    border-right: 1px solid #000000;
    border-left-style: solid;
    border-bottom-style: none;
    border-left-width: 1px;
    border-left-color: #000000;
    table-layout: fixed;
    }.tabletitleTD {
    background: #0099FF;
    overflow:hidden;
    height:15;
    border-left:1px solid buttonhighlight;
    border-right:1px solid buttonshadow;
    border-top:1px solid buttonhighlight;
    border-bottom:1px solid buttonshadow;
    color: #FFFFFF;
    }
    .tableAct {
    background: #FFFFFF;
    font: icon;
    color: buttontext;
    border-right: 1px solid threedshadow;
    }
    .tableAct TD{
    border-left: 1px solid buttonshadow;
    }
    .tdwbar{
    cursor:w-resize;
    background:buttonface;
    behavior:url(dragline.htc);
    }
    .tt {
    background-color: #FFFFFF;
    border-top: 1px none #666666;
    border-right: 1px none #666666;
    border-bottom: 1px solid #666666;
    border-left: 1px none #666666;
    white-space: nowrap;
    }
    </style>
    <TABLE  border="0" cellPadding="0" cellSpacing="0"  class="tabletitle" id="tb1">
      <TR> 
        <TD width="100" class="tabletitleTD" >标题1</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="100" class="tabletitleTD" >标题2</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="200" class="tabletitleTD" >标题3</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="50" class="tabletitleTD" >标题4</TD>
        <TD width="1" rowspan="4" class="tdwbar" ></TD>
        <TD width="200"  bgcolor="#0099FF" class="tabletitleTD" >rerewr</TD>
    <!--   <td width="150" height="9" align="center" class="tabletitleTD" >职级</td>
                <td width="1" rowspan="2"  class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" >描述</td>
                <td width="1" rowspan="2" class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d3 >人头总数</td>
                <td width="1" rowspan="2" class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d4>合共工资</td>
                <td width="1" rowspan="2"class="tdwbar" ><img src="Image_C/bg01.gif" width="1" height="1"></td>
                <td width="150" align="center" class="tabletitleTD" id=d5>涨幅 %</td>-->
      </TR>
      <TR> 
        <TD class="tt">123</TD>
        <TD width="100" class="tt">123</TD>
        <TD width="200" class="tt" style='word-break:break-all'>3463464reyhdytwru868w568asdfasdhadfhadhf</TD>
        <TD width="50" class="tt">66</TD>
        <TD width="200"   class="tt">88</TD>
      </TR>
      <TR> 
        <TD height="20" class="tt">123</TD>
        <TD width="100" class="tt">111</TD>
        <TD width="200" class="tt">44</TD>
        <TD width="50" class="tt">77</TD>
        <TD width="200"   class="tt">iiii</TD>
      </TR>
      <TR> 
        <TD class="tt">46</TD>
        <TD width="100" class="tt">5645</TD>
        <TD width="200" class="tt">757</TD>
        <TD width="50" class="tt">757</TD>
        <TD width="200"   class="tt">456</TD>
      </TR>
    </TABLE>
    style='word-break:break-all'
    table-layout: fixed;
      

  16.   

    我觉得是不是我们俩的想法有点不一样。呵呵……我看了你后来的,我所说的TABLE扩宽,是指最后一条竖线也能移动。呵呵……。不过你真是历害啊。
      

  17.   

    你是说这样吗?吧最外层的div去掉,或者百table外面的两个div都去掉
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <style>
    .tabletitle {
    font: icon;
    color: buttontext;
    background: threedhighlight;
    border-top:1px solid #000000;
    border-right: 1px solid #000000;
    border-left-style: solid;
    border-bottom-style: none;
    border-left-width: 1px;
    border-left-color: #000000;
    }
    .tabletitleTD {
    background: #0099FF;
    overflow:hidden;
    height:15;
    border-left:1px solid buttonhighlight;
    border-right:1px solid buttonshadow;
    border-top:1px solid buttonhighlight;
    border-bottom:1px solid buttonshadow;
    color: #FFFFFF;
    }
    .tableAct {
    background: #FFFFFF;
    font: icon;
    color: buttontext;
    border-right: 1px solid threedshadow;
    }
    .tableAct TD{
    border-left: 1px solid buttonshadow;
    }
    .tdwbar{
    cursor:w-resize;
    background:buttonface;
    behavior:url(dragline.htc);
    }
    .tt {
    background-color: #FFFFFF;
    border-top: 1px none #666666;
    border-right: 1px none #666666;
    border-bottom: 1px solid #666666;
    border-left: 1px none #666666;
    white-space: nowrap;
    }
    .myscroll{FONT-SIZE: 12px;SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF;SCROLLBAR-SHADOW-COLOR: #e1e1e1;SCROLLBAR-3DLIGHT-COLOR: #e1e1e1;SCROLLBAR-TRACK-COLOR: white;  SCROLLBAR-DARKSHADOW-COLOR: white; scrollbar-Base-Color: white; scrollbar-arrow-Color:}
    </style>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function TTable(name){
        this.name=name;
    this.cols=new Array();
    this.rows=new Array();
    this.items=new Array();
    this.colcount=0;//实际是列输减一
    this.rowcount=0;
    this.data=new Array();
    //style
    this.width=100;//colum width
    this.bgc="#e7e7e7";
    this.fontfamily="tahoma,arial,helvetica";
        //method
    this.addData=addData;
    this.trimData=trimData;
    this.create=create;
    this.display=display;
    this.refresh=refresh;
    }
    function TItem(owner,name,data,rindex,cindex,width,bgc,ftc){
        this.owner=owner;
    this.name=name;
    this.data=data;
    this.rindex=rindex;
    this.cindex=cindex;
    this.width=width||owner.width;
    this.bgc=bgc||owner.bgc;
    this.htmlcode=!rindex?'\n<TD width="100" class="tabletitleTD" >'+data+'</TD>\n<TD width="2" rowspan="'+owner.colcount+'" class="tdwbar" ></TD>':'\n<TD class="tt">'+data+'</TD>';
    }function addData(){
        var arg=addData.arguments;
        var len=arg.length;
    this.colcount=Math.max(this.colcount,len);
        var tmpdata=new Array();
    for(i=0;i<this.colcount;i++){
        tmpdata[i]=!arg[i]?'':arg[i];
    }
    this.data[this.data.length]=tmpdata;
    }
    function trimData(){
        for(i=0;i<this.data.length;i++){
        for(j=0;j<this.colcount;j++){
        this.data[i][j]=!this.data[i][j]?'&nbsp;':this.data[i][j];
    }
    }
    }
    function create(){
        for(i=0;i<this.data.length;i++){
        this.items[i]=new Array;
    for(j=0;j<this.colcount;j++){
        this.items[i][j]=new TItem(this,this.data[i][j],this.data[i][j],i,j)
    }
        }
    }
    function display(){
        this.htmlcode='';
    //this.htmlcode+='\n<div id="MainBG" style="position:absolute; left:100px; top:180px; z-index:1; ;border: 1px none #000000;overflow:auto;" class=myscroll>'
           this.htmlcode='\n<div id="TableBG" style="position:absolute; left:0px; top:0px; z-index:2; border: 1px none #000000">'
     +'\n<TABLE  border="0" cellPadding="0" cellSpacing="0"  class="tabletitle" id="tb1">'; for(i=0;i<this.data.length;i++){
        this.htmlcode+='\n<tr>';
        for(j=0;j<this.colcount;j++){
       this.htmlcode+=this.items[i][j].htmlcode;
    }
    this.htmlcode+='\n</tr>';
        }
    this.htmlcode+='</table></div>'//+'</div>';
    document.write(this.htmlcode)
    }
    /*******************  drag function  ************************/
    function TDrag(){
       this.x1=null;
       this.x2=null;
       this.obj=null;
       this.tableW=null;
       this.tdW=null;
       this.table=null;
       this.targetTD=null;
    }
    function getTdSid(sid){
       var targetSID=sid-1;
       while(document.all[targetSID].tagName!='TD'){targetSID--}
       return targetSID
    }
    function mDown(){
        oDrag.obj=window.event.srcElement;
        if(oDrag.obj.tagName=='TD'&&oDrag.obj.rowSpan!=1){
         document.body.style.cursor="e-resize";
        var targetSID=getTdSid(event.srcElement.sourceIndex);
            oDrag.targetTD=document.all[targetSID];
    oDrag.table=event.srcElement.parentElement.parentElement.parentElement;
        oDrag.tableW=table.clientWidth;
        oDrag.x1=event.x
    }else{
        oDrag.obj=null;
        return false
    }}
    function mMove(){
       if(!oDrag.obj)return false;
       try{
      // if(window.event.x>=(MainBG.offsetLeft+MainBG.clientWidth))return false;
    oDrag.x2=event.x;
    var dW=oDrag.x2-oDrag.x1;
    oDrag.targetTD.style.width=oDrag.targetTD.clientWidth+dW
    oDrag.table.style.width=dW+oDrag.tableW;//------------>!!!
    }
    catch(x){}
    }
    function mUp(){
      document.body.style.cursor="default";
      oDrag.obj=null;
    }
    function refresh(){
       table=TableBG.children[0]
       TableBG.style.width=table.clientWidth;
       TableBG.style.height=table.clientHeight;
    //   MainBG.style.width=(TableBG.clientHright>=500)?500:TableBG.clientWidth;
    //   MainBG.style.height=(TableBG.clientHright>=500)?500:TableBG.clientHeight+16;//默认,高度超过500px使用滚动
    }
    function dragInit(){
           oDrag=new TDrag();
       document.onmousedown = mDown
       document.onmousemove = mMove
       document.onmouseup = mUp;
    }
    //-->
    </SCRIPT>
    </HEAD><BODY onload="dragInit()"><SCRIPT LANGUAGE="JavaScript">
    <!--
    ot=new TTable();
    ot.addData('name','email','phoneCode','address','homepage','oicq')
    ot.addData('llrock','[email protected]','123456789','Beijing','user1.7host.com/ccrock','1234567')
    ot.addData(1,2,3,4)
    ot.addData(1,2,'',4,5,6)
    ot.addData(1,2,3,4,5)
    //ot.data=[[1,2,3,4],2,3]
    ot.trimData()
    ot.create()
    ot.display()
    ot.refresh()
    //-->
    </SCRIPT>
    </BODY>
    </HTML>