Adding rows to a table Dynamically!

Results 1 to 3 of 3

Thread: Adding rows to a table Dynamically!

  1. #1
    Join Date
    Dec 1969

    Default Adding rows to a table Dynamically!

    I need to add an extra row to an existing HTML table when I click on Add Row botton of the page. A blank row should be added at the lst but one position. i.e if I have total of 5 rows in a table and when I click on AddRow button I should get a blank row at the 4th row posttion. Can I do this with Java Script? Can any one explain me how?<BR><BR>Thanks in advance

  2. #2
    Arky Guest

    Default RE: Adding rows to a table Dynamically!

    You can do this using Javascript and DHTML i did it once a while ago and it was a pain in the ***, and i really dont feel like looking it up, maybe someone else will. The biggest problem was that Netscape would not support adding the field.<BR><BR>All you do is create an array with the table rows in it. Then you have a function that prints them out. When they click add row, you simply call another function that adds to the array and prints. <BR><BR>Another very easy way to go about doing it is this.<BR>Simply make the Add Row a Submit button back to its self (same page), you send it a parameter (variable) that then writes the page with the added row. (this uses ASP though)<BR><BR>I just thought i would give it what i had real quick wish i could be of more help.<BR>Arky

  3. #3
    Dan Evans Guest

    Default RE: Adding rows to a table Dynamically!

    This article shows you how to use the Table object model in IE4+...<BR><BR>...but as it&#039s IE only it&#039s not perfect. If you know your target will be using DHTML (IE4+ or NS4+) then you could create a DIV and write the table into it. Whenever the content needs to be changed, just rewrite the DIV (using .innerHTML or .write)<BR><BR>If you know the targets might have poor browsers so you don&#039t want it to be dynamic then you&#039ll have to rely on creating the table on the server like Arky says. Of course you could check for the browser version and then send them the appropriate code since DHTML is much slicker than having to go back and forth between the server and client and worth using if you can.<BR><BR>Hope this helps,<BR><BR>-Dan Evans

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts