creation of table using method in DHTML page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Navdip
    New Member
    • Mar 2008
    • 22

    creation of table using method in DHTML page

    i want to create a DHTML page in which i want to create a Table using method in JSCRIPT
    in which i'll pass the number of rows and coloumns as arguments of method.
    and table should get created when i call the method

    please give me code if u can.....
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by Navdip
    i want to create a DHTML page in which i want to create a Table using method in JSCRIPT
    in which i'll pass the number of rows and coloumns as arguments of method.
    and table should get created when i call the method

    please give me code if u can.....
    An exiting thread may help you.

    In that code given in that thread, table is already created, only rows and fields are added.

    To add table use this:[code=javascript]
    var tbl = document.create Element("table" );
    var tblBdy = document.create Element("tbody" );
    tbl.appendChild (tblBdy);
    document.getEle mentsByTagName( "body")[0].appendChild(tb l);[/code]

    Comment

    • Navdip
      New Member
      • Mar 2008
      • 22

      #3
      function createTable(lis t)
      {
      alert(list);
      var table= document.create Element('Table' );

      table.border='1 ';
      var tbdy=document.c reateElement('T BODY');
      while(list)
      {
      var tr=document.cre ateElement('TR' );
      tbdy.appendChil d(tr);
      }

      // table.appendChi ld(tbdy);
      // var tr=document.cre ateElement('TR' );
      // tbdy.appendChil d(document.crea teTextNode(Navd ip,Singh);

      "list has total number of rows. which return web service"

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        Look at the code I gave you, and try to change it according to your needs.

        First create the table and tbody, then append the table to the body, as I had done in the code above.

        Then to create rows, look at the insR() function in the link I gave you, and copy line number 4 to 10 from that code.

        Regards,
        Harpreet

        Comment

        Working...