Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts

    Can't display a table row via Ajax

    I'm trying to click on a link and via Ajax, get a table row to display updated data. I have it all working except it displays at the top of the table instead of inside the table at the desired row.

    For now, I'm just trying to add a simple table row using:

    Code:
    <TR><TD>test</TD></TR>
    Here is my table code:
    Code:
    <TABLE>
    <TR><TD>one</TD></TR>
    <TR><TD>two</TD></TR>
    <span id="id_row3"></span>
    </TABLE>
    So when I click on my link to execute the ajax code, I expect to see a table row inserted with the text "four" but "four" displays at the top of the web page, above the table itself. How can I get the new row to insert at the id_row3 tag?

    Thanks for any help...
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    1. Get rid off the span ... it is not allowed like this inside a table
    2.
    Code:
    var newTR = document.createElement('tr');
    var newTD = document.createElement('td');
    var newText = document.createTextNode('test');
    newTD.appendChild(newText);
    newTR.appendChild(newTD);
    document.getElementsByTagName('table')[0].getElementsByTagName('tbody')[0].appendChild(newTR);

  • Users who have thanked devnull69 for this post:

    rfresh (08-01-2011)


  •  

    Posting Permissions

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