<style>
table {font-size = 9pt}
td {height = 20px}
</style>
<body>
<span id="menus"></span>
<span id="view"></span>
</body>
<script for=pad event=onclick>
// 大類節點點擊響應
for(var i=1;i<this.parentElement.rows.length;i =2)
this.parentElement.rows[i].style.display = "none";
this.parentElement.rows[this.rowIndex 1].style.display='block';
view.innerHTML = this.v1 ":" this.v2; // 根據大小類自行構造相應動作
</script>
<script for=bar event=onclick>
// 小類節點點擊響應
view.innerHTML = this.v1 ":" this.v2; // 根據大小類自行構造相應動作
</script>
<script>
/**
* 產生菜單的html代碼串
* 入口參數為菜單預設開啟的大類號
*/
function menu(n) {
this.ar = new Array(
/**
* 參數數組
* 列1:大類
* 列2:小類
* 列3:標題
*/
new Array(1,0,"大類一"),
new Array(1,1,"小類一"),
new Array(1,2,"小類二"),
new Array(2,0,"大類二"),
new Array(2,1,"小類一"),
new Array(2,2,"小類二"),
new Array(2,3,"小類三"),
new Array(3,0,"大類三"),
new Array(3,1,"小類一"),
new Array(3,2,"小類二"),
new Array(4,0,"大類四"),
new Array(4,1,"小類一"),
new Array(4,2,"小類二"),
new Array(4,3,"小類三")
);
this.width =120;
this.bgcolor = "#f0f0f0";
this.bordercolorlight = "#c0c0c0";
this.bordercolordark = "#FFFFFF";
this.tr_bgcolor = "#d0d0d0";
var s = "<table border=1 align=center width=" this.width " bgcolor=" this.bgcolor " bordercolorlight=" this.bordercolorlight " bordercolordark=" this.bordercolordark " CELLPADDING=0 CELLSPACING=0>"
for(var i=0;i<this.ar.length;i ) { // 構造菜單的html結構,其中將大小類編號作為自訂參數,以便事件響應時使用。
if(this.ar[i][1] == 0) {
if(i > 0)
s = "</table></td></tr>";
var vk = this.ar[i][0]==n?"block":"none";
s = "<tr id='pad' bgcolor=" this.tr_bgcolor " v1=" this.ar[i][0] " v2=" this.ar[i][1] "><td align=center>" this.ar[i][2] "</td></tr><tr style='display:" vk "'><td><table width=100%>";
}else
s = "<tr><td id='bar' v1=" this.ar[i][0] " v2=" this.ar[i][1] ">" this.ar[i][2] "</td></tr>";
}
s = "</table></td></tr></table>";
return s;
}
/*** 建立菜單 ***/
menus.innerHTML = menu(4);
</script>