try this code.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Matrix for Life</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#newtable{
border-left:2px solid #999;
border-right:2px solid #999;
font-family:verdana,arial,helvetica,sans-serif;
font-size:18px;
margin:auto;
}
input.node{
hight: 45px;
width: 55px;
border:1px doted #999;
}
MatA{
}
</style>
<script type="text/javascript">
function AddMatrix() {
row=new Array();
cell=new Array();
row_num=document.getElementById("noofrows").value;
cell_num=document.getElementById("noofcols").value;
tab=document.createElement('table');
tab.setAttribute('id','newtable');
tbo=document.createElement('tbody');
for(c=0;c<row_num;c++){
row[c]=document.createElement('tr');
row[c].TagName="tr";
for(k=0;k<cell_num;k++) {
cell[k]=document.createElement('td');
cell[k].TagName="td";
var input = document.createElement("input");
input.type = "text";
input.name = 'node'+c+','+k;
input.setAttribute('class','node');
cell[k].appendChild(input);
row[c].appendChild(cell[k]);
}
tbo.appendChild(row[c]);
}
tab.appendChild(tbo);
document.getElementById('mytable').appendChild(tab);
}
</script>
<script type="text/javascript">
function show1()
{
var tblData = new Array();
var table = document.getElementById("newtable");
var i;
var txt;
var txt2;
tr = table.getElementsByTagName('tr');
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName('td');
var td2 = td[1].childNodes[0].value;
var td1 = td[0].childNodes[0].value;
var td3 = td[2].childNodes[0].value;
var val = td1+td2+td3;
alert(val);
}
}
</script>
</head>
<body>
<div>
<h3>Matrix</h3>
Number of Rows: <input type="text" id="noofrows" value='2' />
Number of Colomns: <input type="text" id="noofcols" value='3'/>
<input type="button" id="add" value="Add" onclick="AddMatrix()"/>
</div>
<div id="mytable"></div>
<input type="button" id="show" value="Show" onclick="show1()"/>
</body>
</html>