请帮忙处理以下场景 ->
我想在表格中以一种方式显示从1到30的数值,使得1、2、3等数字在一个标签中显示,4、5、6等数字在另一个标签中显示,以此类推,直到30。我想使用表格来显示元素中的数值,其中每个值如“1”应在一个
我的意思是,值“1”应在
我想在表格中以一种方式显示从1到30的数值,使得1、2、3等数字在一个标签中显示,4、5、6等数字在另一个标签中显示,以此类推,直到30。我想使用表格来显示元素中的数值,其中每个值如“1”应在一个
<TD>
中显示,如“2”应在不同的<TD>
中显示,依此类推。我的意思是,值“1”应在
<Table>
标签的单个<TD>
中显示,值“2”应在另一个<td>
标签中显示,以此类推,每三个连续的<TD>
后应使用一个<Tr>
。输出应如下所示 ->1 2 3
4 5 6
7 8 9
希望能尽早得到回复。谢谢。
我已经尝试了以下给出的代码,
等等!
<script type="text/javascript">
document.write(" <table width='673' align='center' cellpadding='2' cellspacing='1'>");
document.write(" <tr>");
document.write(" <td valign = 'top'>");
document.write(" </td>");
document.write(" </tr>");
var cnt = 0;
for (var idx = 1; idx <= 30; idx++)
{
cnt = cnt + 1;
document.write(" <tr>");
document.write(" <td valign = 'top'>");
document.write(" <table width='100px' align='center' cellpadding='2' cellspacing='1'>");
document.write(" <tr>");
document.write(" <td align='center'>");
document.write(" " + idx + "");
document.write(" </td>");
document.write(" </tr>");
document.write(" <tr>");
document.write(" <td class='label'>");
document.write(" <span> name part : " + idx + "</span>");
document.write(" </td>");
document.write(" </tr>");
document.write(" </table>");
document.write(" </td>");
if (cnt = 3)
{
document.write(" </tr>");
}
if (cnt = 3) {
cnt = 0;
}
}
document.write(" </table>");
</script>