Replacing Tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Leo Smith
    New Member
    • Mar 2007
    • 45

    Replacing Tables

    Hello,

    I am trying to replace a table that is setting inside a div tag. The reason is that I want to replace a table through AJAX instead of using postbacks or Iframes. The table is built on the server then sent back to the webpage as a string. I am trying to avoid parsing the string and recreating every control within the object. I had hoped that I could use innerHtml on the div tag, but this doesn't work. Does anyone know of an article already written on this that I could use. Final note, the solution needs to work with lastest version of Firefox (MAC and Windows versions) and IE 7.

    Thanks,
    Leo
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN - TheScripts.

    What code do you have so far?

    Comment

    • Leo Smith
      New Member
      • Mar 2007
      • 45

      #3
      Replacing Table on Clientside

      I would like to know if there is an easy to replace a table and its contents on the client side. I am using AJAX to return a string that holds all the table and its contents as it would appear in an HTML page. The table is currently setting inside a div tag, but if there is an easier way, I am game. I had thought that that document.getEle mentById('eleme nt').innerHtml = data would work, but it doesn't remove or replace the contents. I am trying to avoid parsing and building the table by creating every row, cell and contents individually. The solution needs to be a cross platform solution (firefox and IE at least).

      Thanks,
      Leo
      Last edited by Leo Smith; Mar 8 '07, 01:51 PM. Reason: Another post I had just found that I thought was lost

      Comment

      • Leo Smith
        New Member
        • Mar 2007
        • 45

        #4
        <pre>
        function RefreshTable(re sult, context)
        {
        if(result == null || result == "")
        alert("Error updating database");
        else
        {
        // replace table
        var data = result.split("| "); // Split list into two pieces
        // First piece is control id, second table string
        if(data.length == 2)
        {
        document.getEle mentById(data[0]).innerHtml = data[1];
        }
        }
        return false;
        }
        </pre>

        This is the function that does the update. Result is in two pieces. The first is the name of the div tag, the second is literally a string of text that has everything for the table formatted like the table would be described in standard html.

        Thanks,
        Leo

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Merged threads.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            innerHtml should be innerHTML. Javascript is case-sensitive.

            Comment

            • Leo Smith
              New Member
              • Mar 2007
              • 45

              #7
              Thanks, that was it. Is there a location that has a list of the standard tags and thier properties, functions and events?

              Thanks,

              Leo

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8

                Comment

                Working...