Skip to content

Instantly share code, notes, and snippets.

/asd

Created November 6, 2013 05:28
Show Gist options
  • Save anonymous/7331383 to your computer and use it in GitHub Desktop.
Save anonymous/7331383 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Projects</title>
<style type="text/css">
#newtable
{
width:60%;
border:3px solid brown;
font-size:18px;
border-collapse: collapse;
border-spacing: 0;
}
#newtable td
{
width:200px;
background-color:gray;
border:2px solid brown;
text-align:center;
}
</style>
<script type="text/javascript">
function makeTable()
{
var row_num = 20;
var cell_num = 4;
var tab = document.createElement('table');
tab.setAttribute('id','newtable');
var tbo = document.createElement('tbody');
tbo.setAttribute('id','tabody');
var cont;
for(var c = 0 ; c < row_num ; c++)
{
var row = document.createElement('tr');
for(var k = 0 ; k < cell_num ; k++)
{
var cell = document.createElement('td');
if (k > 0)
{
cont = document.createElement("input");
cont.setAttribute('type','text');
}
else
{
cont = document.createTextNode("0" + (c+1));
}
cell.appendChild(cont);
row.appendChild(cell);
}
tbo.appendChild(row);
}
tab.appendChild(tbo);
document.body.appendChild(tab);
tab.setAttribute("align", "top-left");
}
function GetCellValues()
{
// returns an array with all the elements, not just one
var rows = document.getElementsByTagName('tr');
for(var c = 0 ; c < rows.length ; c++)
{
var row = rows[c];
var inputs = row.getElementsByTagName('input');
for(var k = 0 ; k < inputs.length ; k++)
{
console.log(inputs[k].value);
}
}
}
window.onload = function()
{
makeTable();
};
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment