<script type="text/javascript"> var rsCount = 1234; //记录数 var rowMax = 4; //最大行数 function show() { var str = ''; str += '<table>'; var cursor = 0; var i = 1; var maxColumn = rsCount % 4 == 0?rsCount/4:parseInt(rsCount/4)+1; while(cursor < rsCount) { switch (i % maxColumn) { case 0: str += '<td>'+i+'</td></tr>';break; case 1: str += '<tr><td>'+i+'</td>';break; default: str += '<td>'+i+'</td>'; } cursor++; i++; } str +='</table>'; document.write(str); } show(); </script>
由记录集数自动生成表格,行数为定值的情况
最新推荐文章于 2008-07-16 08:05:00 发布