Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to display this dynamic table by default?
    primarykey
    data
    text
    <p>I have this code for dynamic HTML, but i cannot display this by default, the table is being displayed when I select the option, jsfiddle: <a href="http://jsfiddle.net/4DYCm/" rel="nofollow">http://jsfiddle.net/4DYCm/</a></p> <p>HTML:</p> <pre><code> &lt;tr&gt; &lt;th&gt;Number of Models:&lt;title="Number of Models"&gt;&lt;/th&gt; &lt;td&gt;&lt;select id="numbermodels" name="numbermodels" autocomplete="off" onchange="buildTable(this.value);" &gt; &lt;option value="1" &gt;1&lt;/option &gt; &lt;option value="2" &gt;2&lt;/option &gt; &lt;option selected="selected" value="3" &gt;3&lt;/option &gt; &lt;option value="4" &gt;4&lt;/option &gt; &lt;option value="5" &gt;5&lt;/option &gt; &lt;option value="6"&gt;6&lt;/option &gt; &lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; &lt;table id="contentTable" border="1" name="contentTable"&gt; &lt;!-- Fill table programmatically --&gt; &lt;/table&gt; </code></pre> <p>JavaScript:</p> <pre><code> function buildTable(val) { var myTable =document.getElementById("contentTable"); var j=val; var rows = []; var cells = []; while (myTable.hasChildNodes()) { myTable.removeChild(myTable.lastChild); } for( var i = 0; i &lt; 1; i++ ) { rows[i] = myTable.insertRow(i); if(i%3==2)rows[i]; cells[i] = []; for( var x = 0; x &lt; j ; x++ ) { cells[i][x] =document.createElement((x==0)?"th":"td"); cells[i][x].innerHTML = (x==0)?"&lt;input id=t name=t[] size=3&gt;":"&lt;input id=t1 name=t1[] size=3&gt;"; rows[rows.length - 1].appendChild(cells[i][x]); } } } buildTable(); </code></pre> <p>I tried giving onload in place of onchange, but when I give this, the table is not being generated, can someone tell me how to display this table by default ?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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