Create user-defined table in HTML
<p>What I want, is creating a table using HTML and JS.</p>

<p>The first line is the header of the table which shall be set in advance.<br>
The number of rows in the table should be entered at the top of the HTML Document (before the table is created, that is).</p>

<p>What I am struggeling with is the transportation of the variable "nr" (number of rows) into the JS function (tried testing with alert).</p>

<p>Also, if someone has a good idea how to actually create the table it'd be much apreciated. </p>

<hr>

<p>This is what I've got so far:</p>

<pre><code>&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt; The Hausarbeit&lt;/title&gt;
        &lt;script type="text/javascript"&gt;
            function makeTable() {
                /*r=document.getElementById("zeilen").value;
                var table=document.getElementById("myTable");
                for(i=1;i&lt;=parseInt(r);i++){
                var row=table.insertRow(i);
                var y=r.insertCell(0);
                    y.innerHtml=i.value;*/
                var zeilen;
                zeilen = document.getElementById("zeilen").value;
                alert('zeilen.value');
            }

            function random() {

            }
        &lt;/script&gt;
        &lt;style type="text/css"&gt;
            table,
            td {
                border: 2px solid black;
            }
        &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div&gt; Anzahl der Arbeitspakete=
            &lt;input type="text" id="zeilen" /input&gt;
            &lt;input type="button" value="Tabelle erstellen" onClick="makeTable()" /input&gt;
            &lt;input type="button" value="Test Werte" onClick="random" /input&gt;
        &lt;/div&gt;
        &lt;table id="myTable"&gt;
            &lt;tr&gt;
                &lt;td&gt;T&amp;auml;tigkeit&lt;/td&gt;
                &lt;td&gt;Dauer&lt;/td&gt;
                &lt;td&gt;Vorg&amp;auml;nger&lt;/td&gt;
                &lt;td&gt;FAZ&lt;/td&gt;
                &lt;td&gt;FEZ&lt;/td&gt;
                &lt;td&gt;SAZ&lt;/td&gt;
                &lt;td&gt;SEZ&lt;/td&gt;
                &lt;td&gt;Puffer&lt;/td&gt;
            &lt;/tr&gt;
        &lt;/table&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Also, the number of columns is supposed to be 8 per row, the first 3 cells of every row are supposed to be changeable, so one is able to let another script calculate and display a critical path analysis with that table.</p>

<p>Any help would be much appreciated, since this is homework due at Apr.11th.
Thanks a lot in advance!</p>

<p>UPDATE:
Since it seems I didn't specify my question/Problem clearly enough, I'm adding some pseudocode to the question :</p>

<pre><code>User input: number of rows&gt;&gt;n;
Button onClick: js creates table: n rows, 8 columns; couple of strings for table header;
First column: count 1 to n;
2nd column: cells editable by user&gt;&gt;duration;
3rd column: cells editable by user&gt;&gt;required_packages (separated by ",") 

using the given information (duration and required packages) the below values shall be calculated and filled into the table by pressing a button at the bottom
(one package can depend on more than one package, dependencies work recursively
[e.g. 2 depends on 1, 3 depends on 2, so 3 depends on 1 recursively]) 

4th column: FAZ (earliest time the work package can be started) 
5th column: FEZ (earliest time the work package can be finished) 
6th column: SAZ (latest time the work package can be started)
7th column: SEZ (latest time the work package can be finished) 
//note to 6 and 7: without the entire project getting delayed (dependencies) 
8th column: time difference between 6th and 7th column  (alternatively 4th and 5th column, doesn't matter since difference is the same)
</code></pre>

<p>Hope that helped you helping me! 
Again, thanks a lot! :D</p>