how to insert data into existing table row

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • koyanpaing
    New Member
    • Mar 2010
    • 26

    how to insert data into existing table row

    Hi everyone,

    I would like to know about how to insert data into existing table row.
    here is my javascript file.

    Code:
    function addDataToRows(tableID,noOfRows,data) {
    	var table = document.getElementById(tableID);
    	var rowCount = table.rows.length-noOfRows;
    And i want to insert data to that row.

    Thanks and Regards
    Yan Paing
    Last edited by Dormilich; Mar 26 '10, 06:30 AM. Reason: Please use [code] tags when posting code
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Hi Yan,
    I am just considering that there is only one 'td' in ur table and i had wrote a script for that. This is the way you have to add dynamic data.

    Code:
      var myTab = document.getElementById(tableID);
       var row=myTab.rows.length; 
       var y=myTab.insertRow(row);
    
       var a=y.insertCell(0);
       var xx= document.createElement('input');
       xx.type="text";
       a.appendChild(xx);
    If you have more no of td's means u can insertCell(n). You have to repeat it again.

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    Working...