1
<tbody id="contacttable">
</tbody>
<script> 
  var hrtypeCode = document.getElementById('hrtypeCode').value;
  var hrCode = document.getElementById('hrCode').value;
  var hrName = document.getElementById('hrName').value;
  var hrDesc = document.getElementById('hrDesc').value;
  for(i=0;i<hrCode.length; i++){        
    if(hrCode[i]!="") {
      var table = document.getElementById("contacttable");
      var slNo = table.rows.length;
      var tr = table.insertRow(slNo-1);
      tr.id = 'list_tr_' + slNo;
      tr.innerHTML ='<td><input type="text" name="hrtypeCode" value="'+hrtypeCode[i]+'" ></td><td><input type="text" name="hrCode" value="'+hrCode[i]+ '"></td><td><input type="text" name="hrName" value="'+hrName[i]+'" ></td>';
      count++;
    }
  }
</script> 
<i>

how to find out the cell values.i have tried the following code but it showing entire TD row

tbl.rows[i].cells[j].innerHTML);
  alert(tbl.rows[i].cells[j].innerHTML);  

Kindly help in finding the value.. thanks.

RevanProdigalKnight
  • 1,316
  • 1
  • 14
  • 23
Krishnamoorthy
  • 1,236
  • 11
  • 17

1 Answers1

0

Table cells don't have values, only input elements do. You need to access the <input> element within the table cell.

Use:

tbl.rows[i].cells[j].getElementsByTagName("input")[0].value

DEMO

Barmar
  • 741,623
  • 53
  • 500
  • 612