title: Generate Html table using for loop
body: <p>Please help with below mentioned scenario-></p>
  
  <p>I am having wanna display values from 1 to 30 in a table such a way that nos 1,2,3 should come in one tag and like wise 4,5,6 in other tr tag ans so on till 30 value. I wanna use table for displaying values in a element of a table. wherein each value like "1" should display in one , no "2" should display in different <code>&lt;TD&gt;</code> and so on.</p>
  
  <p>I mean to say that value "1" should be displayed in single <code>&lt;TD&gt;</code> of <code>&lt;Table&gt;</code> tag ,value "2" should be displayed in another <code>&lt;td&gt;</code> tag and so on ,Also after three subsequent <code>&lt;TD&gt;</code>s one <code>&lt;Tr&gt;</code> should be used. Output should be as folllows -> </p>
  
  <pre><code>1 2 3 
  4 5 6
  7 8 9
  </code></pre>
  
  <p>and so on!</p>
  
  <p>Early response would be much appreciated. Thanks.</p>
  
  <p>I have tried Code as given below, </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      document.write("        &lt;table width='673' align='center' cellpadding='2' cellspacing='1'&gt;");
      document.write("            &lt;tr&gt;");
      document.write("    &lt;td valign = 'top'&gt;");
      document.write("                &lt;/td&gt;");
  
      document.write("            &lt;/tr&gt;");
  
      var cnt = 0;
      for (var idx = 1; idx &lt;= 30; idx++) 
      {
          cnt = cnt + 1;
          document.write("            &lt;tr&gt;");
              document.write("    &lt;td valign = 'top'&gt;");
              document.write("        &lt;table width='100px' align='center' cellpadding='2' cellspacing='1'&gt;");
              document.write("            &lt;tr&gt;");
              document.write("                &lt;td align='center'&gt;");
              document.write("                   " + idx + "");
              document.write("                &lt;/td&gt;");
              document.write("            &lt;/tr&gt;");
              document.write("            &lt;tr&gt;");
              document.write("                &lt;td class='label'&gt;");
              document.write("                    &lt;span&gt; name part : " + idx + "&lt;/span&gt;");
              document.write("                &lt;/td&gt;");
              document.write("            &lt;/tr&gt;");
              document.write("            &lt;/table&gt;");
              document.write("                &lt;/td&gt;");
              if (cnt = 3) 
              {
                  document.write("            &lt;/tr&gt;");
              }
              if (cnt = 3) {
                  cnt = 0;
              }
  
          }
  
      document.write("            &lt;/table&gt;");
  &lt;/script&gt;
  </code></pre>