<html>
<head>
<title>3 dimension arrays</title>
<script type="text/javascript">
var Z = new Array(10);
// initialize 3 dimension array
for (var z=0; z<10; z++) {
Z[z] = new Array(10);
for (var y=0; y<10; y++) {
Z[z][y] = new Array(10);
for (var x=0; x<10; x++) {
Z[z][y][x] = 'Z'+z+'Y'+y+'X'+x;
}
}
}
function DisplayZ(zndx) {
// alert(Z[zndx].join('n'));
var str = '';
str += '<table border="1"><tr>';
for (var y=0; y<10; y++) {
for (var x=0; x<10; x++) {
str += '<td>'+Z[zndx][y][x]+'</td>';
}
str += '</tr><tr>';
}
str += '</tr></table>';
return str;
}
function DisplayY(yndx) {
var str = '';
str += '<table border="1"><tr>';
for (var z=0; z<10; z++) {
for (var x=0; x<10; x++) {
str += '<td>'+Z[z][yndx][x]+'</td>';
}
str += '</tr><tr>';
}
str += '</tr></table>';
return str;
}
function DisplayX(xndx) {
var str = '';
str += '<table border="1"><tr>';
for (var z=0; z<10; z++) {
for (var y=0; y<10; y++) {
str += '<td>'+Z[z][y][xndx]+'</td>';
}
str += '</tr><tr>';
}
str += '</tr></table>';
return str;
}
</script>
</head>
<body>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayZ(0)">Z0</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayZ(1)">Z1</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayZ(2)">Z2</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayZ(3)">Z3</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayZ(4)">Z4</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayZ(5)">Z5</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayZ(6)">Z6</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayZ(7)">Z7</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayZ(
">Z8</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayZ(9)">Z9</button>
<br>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayY(0)">Y0</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayY(1)">Y1</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayY(2)">Y2</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayY(3)">Y3</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayY(4)">Y4</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayY(5)">Y5</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayY(6)">Y6</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayY(7)">Y7</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayY(
">Y8</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayY(9)">Y9</button>
<br>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayX(0)">X0</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayX(1)">X1</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayX(2)">X2</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayX(3)">X3</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayX(4)">X4</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayX(5)">X5</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayX(6)">X6</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayX(7)">X7</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayX(
">X8</button>
<button onclick="document.getElementById('ArrayInfo').innerHTML=DisplayX(9)">X9</button>
<br>
<div id="ArrayInfo"></div>
</body>
</html>