01.
<body>
02.
<select id=
"select1"
onchange=
"displayTable(this)"
>
03.
<option value=
"1"
>1</option>
04.
<option value=
"2"
>2</option>
05.
<option value=
"3"
>3</option>
06.
</select>
07.
<table id=
"table1"
>
08.
<tr>
09.
<th>#</th>
10.
<th>name</th>
11.
</tr>
12.
<tr>
13.
<td>1</td>
14.
<td>a</td>
15.
</tr>
16.
<tr>
17.
<td>2</td>
18.
<td>b</td>
19.
</tr>
20.
<tr>
21.
<td>3</td>
22.
<td>c</td>
23.
</tr>
24.
</table>
25.
<script>
26.
var
trElem = document.getElementById(
'table1'
).getElementsByTagName(
'tr'
);
27.
var
totalTr = trElem.length;
28.
hideTable();
29.
function
displayTable(select){
30.
hideTable();
31.
var
display = parseInt(select.options[select.selectedIndex].value) + 1;
32.
for
(i=0;i<display;i++){
33.
trElem[i].style.display =
"block"
;
34.
}
35.
}
36.
function
hideTable(){
37.
for
(i=0; i<totalTr; i++){
38.
trElem[i].style.display =
"none"
;
39.
}
40.
}
41.
</script>
42.
</body>