lab17js
This commit is contained in:
58
Chapter ZIPs/JavaScript/ch8/ex_8_17.html
Executable file
58
Chapter ZIPs/JavaScript/ch8/ex_8_17.html
Executable file
@@ -0,0 +1,58 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 8.17</title>
|
||||
<script type="text/javascript">
|
||||
function setup()
|
||||
{
|
||||
cells = new Array([document.getElementById("cell00"),document.getElementById("cell01"),
|
||||
document.getElementById("cell02")],[document.getElementById("cell10"),
|
||||
document.getElementById("cell11"), document.getElementById("cell12")],
|
||||
[document.getElementById("cell20"),document.getElementById("cell21"),
|
||||
document.getElementById("cell22")] );
|
||||
placeValues();
|
||||
}
|
||||
// function to place values in cells
|
||||
function placeValues()
|
||||
{
|
||||
for ( rows = 0; rows < 3; rows++ )
|
||||
{
|
||||
for ( var cols = 0; cols< 3; cols++ )
|
||||
{
|
||||
cells[rows][cols].innerHTML = prompt("Enter a value:");
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
table { border: solid #4f81bd; }
|
||||
body { margin: 10ex; color: #4f81bd; font-weight: bold; }
|
||||
td {
|
||||
font-size: 18px; color: #4f81bd; font-weight: bold; margin: 10%;
|
||||
padding: 5px; line-height: 120%; width: 75pt; height: 25pt;
|
||||
text-align: center;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body onload ="setup()">
|
||||
<h1>Loading a 2-Dimensional Array</h1>
|
||||
<table id = "myTable" border = "1">
|
||||
<tr>
|
||||
<td> <span id = "cell00" />cell 00 </td>
|
||||
<td> <span id = "cell01" />cell 01 </td>
|
||||
<td> <span id = "cell02" /> cell 02 </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <span id = "cell10" />cell 10 </td>
|
||||
<td> <span id = "cell11" />cell 11 </td>
|
||||
<td> <span id = "cell12" />cell 12 </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <span id = "cell20" />cell 20 </td>
|
||||
<td> <span id = "cell21" />cell 21 </td>
|
||||
<td> <span id = "cell22" />cell 22 </td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user