Note that there are some explanatory texts on larger screens.

plurals
  1. POdynamic table generator with Java Script
    primarykey
    data
    text
    <p>I try to generate a table dynamicly, based on an user input. The ideea is for the user to insert the number of rows and the html is generated automaticaly. I have made some code and debugged it with jslint, however it does not work, although in jslint there are no significant errors. What am i doing wrong?</p> <p>The code is as follows:</p> <pre><code>&lt;body style="background-color: #777; color: ddd;"&gt; &lt;div style="margin: 20px;"&gt; &lt;h1&gt;Program de calculare determinant matrice de orice grad.&lt;/h1&gt; &lt;/div&gt; &lt;div&gt; Introduceti gradul matricii &lt;input id="grad" type="text" value="" onChange="readGrad ()" &gt; &lt;input style="margin-top: 20px;" type="button" name="Calculate determinant" value="Generati tabel" onClick="genTable (k,k)"&gt; &lt;/div&gt; &lt;form name="Det Matrice"&gt; &lt;div style="margin-top: 100px; float: left; width: 100%;"&gt; Introduceti valorile: &lt;table style="text-align: center;"&gt; &lt;tr id="container"&gt;&lt;/tr&gt; &lt;/table&gt; &lt;br&gt; &lt;/div&gt; &lt;div style="float: left; margin-top: 20px;"&gt; &lt;input type="button" name="Calculate determinant" value="Calculati determinant" onClick="calcDet (k,k);"&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;script&gt; function readGrad() { var k = parseInt(document.getElementById("grad").value); if (isNaN(k)) { alert('Gradul introdus nu este intreg, reintroduceti gradul matricii'); } } function genTable(i, j) { var myTable = '&lt;TABLE BORDER="1"&gt;\n &lt;TBODY&gt;\n'; for (i = 0; i &lt; k; i++) { myTable += ' &lt;TR&gt;\n'; for (j = 0; j &lt; k; j++) { myTable += ' &lt;TD&gt; @ &lt;/TD&gt;\n'; } myTable += ' &lt;/TR&gt;\n'; } myTable += ' &lt;/TBODY&gt;\n&lt;/TABLE&gt;\n'; document.getElementById('container').innerHTML = myTable; } &lt;/script&gt; </code></pre> <p>it can also be checked here: <a href="http://jsfiddle.net/pYc4P/18/" rel="nofollow">http://jsfiddle.net/pYc4P/18/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload