日期:2014-05-17  浏览次数:20813 次

关于输出格式
这样子的   asp比如我在数据库中读取相关内容
主要字段有   地区   区域   姓名
我现在要把他们用表格形式列出来,以地区     区域排序(其中地区区域有单独的表格对应)
当地区区域符合数据各自大于1时
要合并单元格
最原始读取的程序是
sql= "select     *   from   worker   where   (active=1   or   active=2   or   active=3)   order   by   townid,villageid,worker   desc "
显示的是
元谋县   平田   张1      
元谋县   平田   欧2       
元谋县   平田   莫3
我现在要对地名合并单元格


程序怎么写?
补充:对asp还不怎么熟悉




------解决方案--------------------
<script language=javascript>

var towin = new Array();

function addWorker(s1, s2, s3) {
var t, v, w;
if ((towin.length == 0) || towin[towin.length-1].name != s1) {
t = new Object();
t.name = s1;
t.chl = new Array();
towin[towin.length] = t;
} else {
t = towin[towin.length - 1];
}
if ((t.chl.length == 0) || t.chl[t.chl.length-1].name != s2) {
v = new Object();
v.name = s2;
v.chl = new Array();
t.chl[t.chl.length] = v;
} else {
v = t.chl[t.chl.length - 1];
}
w = new Object();
w.name = s3;
v.chl[v.chl.length] = w;
}
addWorker( "元谋县 ", "平田 ", "张1 ");
addWorker( "元谋县 ", "平田 ", "欧2 ");
addWorker( "元谋县 ", "平田 ", "莫3 ");
addWorker( "元谋县 ", "平田1 ", "莫3 ");
addWorker( "元谋县 ", "平田1 ", "莫2 ");
addWorker( "元谋县2 ", "平田 ", "莫3 ");
addWorker( "元谋县2 ", "平田 ", "莫3 ");
addWorker( "元谋县2 ", "平田1 ", "莫2 ");

function mkTAB(obj) {
var rs = " ";
rs = " <table> <tbody> "
for (var i=0; i <obj.length; i++) {
if (obj[i].chl) {
rs += " <tr> <td> <table> <tbody> <tr> <td> " + obj[i].name + " </td> <td> " + mkTAB(obj[i].chl) + " </td> </tr> </tbody> </table> </td> </tr> "
} else {
rs += " <tr> <td> " + obj[i].name + " </td> </tr> "
}
}
rs += " </tbody> </table> "
return rs;
}
var str = mkTAB(towin);
document.write(str);

</script>