I have table and javascript code which should change the value of each input in table. How can I get access to inner cell element?
This is my html code:
<table border="1" id="myTable">
<tr>
<th><input type="text" size="2"></th>
<th><input type="text" size="2"></th>
<th><input type="text" size="2"></th>
<th><input type="text" size="2"></th>
<th><input type="text" size="2"></th>
<th><input type="text" size="2"></th>
</tr>
</table>
And this is my javascript code:
function showSuccess(msg) {
Messenger({
extraClasses: 'messenger-fixed messenger-on-right messenger-on-top',
theme: 'flat'
}).post(msg);
}
function pushArray(){
var oTable = document.getElementById('myTable');
//gets rows of table
var rowLength = oTable.rows.length;
//loops through rows
for (i = 0; i < rowLength; i++) {
//gets cells of current row
var oCells = oTable.rows[i].cells;
//gets amount of cells of current row
var cellLength = oCells.length;
//loops through each cell in current row
for(var j = 0; j < cellLength; j++){
// here i should change the value of input
oCells[j].innerHTML="NEW CONTENT";
}
}
}