Hi,
I dont know how to code to display a certain rows dynamically depending on user's selection. The scenario is like this; when user select value 3, track that having value 3 will be displayed.
My rows are created using innerHTML. I dont have idea how to work around with this code. Pls help.
HTML code:
Code:
<body >
<p>Table of Contents</p>
View by Track:
<select>
<option value="0">--Choose--</option>
<option value="1">1-XX</option>
<option value="2">2-XX</option>
<option value="3">3-XX</option>
<option value="4">4-XX</option>
<option value="5">5-XX</option>
</select>
</p>
<table border="1" >
<tr>
<th>Ref. No.</th>
<th>Track</th>
<th>Title</th>
</tr>
<tbody id="CONTENT"><div id="SHOW"></div>
<script type="text/javascript">
createRows('SHOW');
</script>
</tbody>
</table>
</body>
JavaScript code:
Code:
function createRows() //to create rows using innerHTML
{
var tbody = document.getElementById("CONTENT"); //tbody = your table body
tbody.innerHTML = ""; //empty table body
for (i=1; i<=73; i++)
{
tr = tbody.insertRow(-1); //append a row in table body
td = tr.insertCell(-1); td.innerHTML = referenceNo(i); //ref. no
td = tr.insertCell(-1); td.innerHTML = trackNo(i); //track
td = tr.insertCell(-1); td.innerHTML = getTitle(i); //title and link
}
}