• 締切済み

TABLEの縦横スクロール

エクセルでいうところの「ウィンドウ枠の固定」のように固定行・固定列があり、データ部分において縦横の両方向のスクロールができる表を作成したいのですが、どうにもこうにもできません。。。 どなたか教えてください。

みんなの回答

  • BLUEPIXY
  • ベストアンサー率50% (3003/5914)
回答No.1

試しに作ってみましたが、VBScriptで作ったので、IEのみで動作可能 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=SHIFT_JIS"> <title>テーブルのスクロール</title> <script language="VBScript"> dim data, rows, cols data = Array( _ Array("\","A","B","C","D","E","F","G"), _ Array("1","A1","B1","C1","D1","E1","F1","G1"), _ Array("2","A2","B2","C2","D2","E2","F2","G2"), _ Array("3","A3","B3","C3","D3","E3","F3","G3"), _ Array("4","A4","B4","C4","D4","E4","F4","G4"), _ Array("5","A5","B5","C5","D5","E5","F5","G5"), _ Array("6","A6","B6","C6","D6","E6","F6","G6"), _ Array("7","A7","B7","C7","D7","E7","F7","G7"), _ Array("8","A8","B8","C8","D8","E8","F8","G8"), _ Array("9","A9","B9","C9","D9","E9","F9","G9")) rows=UBOUND(data) cols=UBOUND(data(0)) sub window_onload() dim i for i=0 to UBOUND(data) -1 call insert(i) next end sub sub insert(No) dim newTR, newTD dim rowData dim i set newTR = SHEET.insertRow rowData=data(No) for i=0 to UBOUND(rowData) -1 set newTD=newTR.insertCell newTD.innerText = rowData(i) next end sub sub up() if rows>1 then SHEET.deleteRow(1) rows=rows-1 end if end sub sub down() dim newTR, newTD dim rowData, RSize, CSize dim i RSize = UBOUND(data) CSize = UBOUND(data(0)) if rows < RSize then set newTR = SHEET.insertRow(1) rowData=data(RSize-rows) for i=0 to cols -1 set newTD=newTR.insertCell if i=0 then '表題部分 newTD.innerText = rowData(0) else newTD.innerText = rowData(CSize-cols+i) end if next rows=rows+1 end if end sub sub left() dim i if cols >1 then for i=0 to SHEET.Rows.length -1 SHEET.Rows(i).deleteCell(1) next cols=cols-1 end if end sub sub right() dim newTR, newTD dim rowData, RSize, CSize dim i RSize = UBOUND(data) CSize = UBOUND(data(0)) if cols < CSize then for i=0 to rows -1 set newTD=SHEET.Rows(i).insertCell(1) if i=0 then '表題部分 rowData=data(0) else rowData=data(RSize-rows+i) end if newTD.innerText=rowData(CSize-cols) next cols=cols+1 end if end sub </script> </head> <body> <button type="button" onclick="up()">↑</button> <button type="button" onclick="down()">↓</button> <button type="button" onclick="left()">←</button> <button type="button" onclick="right()">→</button> <TABLE border=1" cellspacing="0"> <TBODY ID="SHEET" STYLE="background-color:lightcyan;"> </TBODY> </TABLE> </body> </html>

関連するQ&A