Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. IE: innerHTML to table id

IE: innerHTML to table id

Scheduled Pinned Locked Moved Web Development
php
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LordLothar
    wrote on last edited by
    #1

    I have response text of table string from php (including the tr and td )and I want to display it in my table with id= "displayCart" as follow:

    <table border=1 id="displayCart" ></table>

    document.getElementById("displayCart").innerHTML = xhr.responseText; It work in Firefox, but not in my IE7.

    L R 2 Replies Last reply
    0
    • L LordLothar

      I have response text of table string from php (including the tr and td )and I want to display it in my table with id= "displayCart" as follow:

      <table border=1 id="displayCart" ></table>

      document.getElementById("displayCart").innerHTML = xhr.responseText; It work in Firefox, but not in my IE7.

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      The last time I had the pleasure :cough: :cough: of working with HTML and TABLE elements dynamically in IE, you had to use DOM methods that created the row and cell elements individually and add them to the table and row respectively. So no, AFAIK, you have never been able to set the innerHTML of a TABLE element in IE.

      L 1 Reply Last reply
      0
      • L led mike

        The last time I had the pleasure :cough: :cough: of working with HTML and TABLE elements dynamically in IE, you had to use DOM methods that created the row and cell elements individually and add them to the table and row respectively. So no, AFAIK, you have never been able to set the innerHTML of a TABLE element in IE.

        L Offline
        L Offline
        LordLothar
        wrote on last edited by
        #3

        Though I have tried before(but I am using javascript) createElement, appendChild and so on, but still doesnt work. I heard IE need tbody and tr must be in that tbody element, but still after creating that still dont work. That makes me not so confident to do it in php. Anyway I should give this a try, but any key/hint that I should know? I havent thought of including thead and tfoot element as I read from some website, any simple example for this that works?

        L 1 Reply Last reply
        0
        • L LordLothar

          Though I have tried before(but I am using javascript) createElement, appendChild and so on, but still doesnt work. I heard IE need tbody and tr must be in that tbody element, but still after creating that still dont work. That makes me not so confident to do it in php. Anyway I should give this a try, but any key/hint that I should know? I havent thought of including thead and tfoot element as I read from some website, any simple example for this that works?

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          LordLothar wrote:

          I am using javascript

          Yes as is this example from your first post.

          LordLothar wrote:

          document.getElementById("displayCart").innerHTML = xhr.responseText;

          But now you say this:

          LordLothar wrote:

          That makes me not so confident to do it in php

          So your post has now become confusing.

          LordLothar wrote:

          createElement, appendChild and so on, but still doesnt work. I heard IE need tbody and tr must be in that tbody element, but still after creating that still dont work.

          Well it does work because we use here in our application so you must have done it wrong.

          L 1 Reply Last reply
          0
          • L led mike

            LordLothar wrote:

            I am using javascript

            Yes as is this example from your first post.

            LordLothar wrote:

            document.getElementById("displayCart").innerHTML = xhr.responseText;

            But now you say this:

            LordLothar wrote:

            That makes me not so confident to do it in php

            So your post has now become confusing.

            LordLothar wrote:

            createElement, appendChild and so on, but still doesnt work. I heard IE need tbody and tr must be in that tbody element, but still after creating that still dont work.

            Well it does work because we use here in our application so you must have done it wrong.

            L Offline
            L Offline
            LordLothar
            wrote on last edited by
            #5

            My bad, what I mean is, first I tried it in JavaScript (never mind about this). Since I use session in php thus I will loop my array and put it in DOM. I should try this before asking, below are example I have to create DOM in php. I will change the element name as html table later. What concern me this will also return string or xml format? to xhr.responseText, in the end I have to display this using innerHTML to tag id I have in my html page. Will that still work in IE?

            ECHO (toXml($myCart));

            function toXml($aCart)
            {
            $doc = new DomDocument('1.0');
            $cart = $doc->createElement('cart');
            $cart = $doc->appendChild($cart);

            foreach ($aCart as $Item => $ItemName)
            { 
            	$book = $doc->createElement('book');
            	$book = $cart->appendChild($book);
            	$title = $doc->createElement('title');
            	$title = $book->appendChild($title);
            	$value = $doc->createTextNode($Item);
            	$value = $title->appendChild($value);
            	$quantity = $doc->createElement('quantity');
            	$quantity = $book->appendChild($quantity);
            	$value2 = $doc->createTextNode($ItemName);
            	$value2 = $quantity->appendChild($value2);
            }
            

            $strXml = $doc->saveXML(); // this serializes the XML as a string
            return $strXml;
            }

            This is my previous post of php code that return string with element tr and td (which doesnt work in IE of course):

            function toHTML($aModel,$aMaker,$aPrice,$aQty)
            {
            $tableString="<tr>
            <th>Manufacturer</th>
            <th>Model</th>
            <th>Price</th>
            <th>Qty</th>
            <th>Total Price</th>
            </tr>";
            foreach ($aModel as $item)
            {
            $tableString .="<tr id='".$aModel[$item]."'>
            <td>".$aMaker[$item]."</td>
            <td>".$aModel[$item]."</td>
            <td>".$aPrice[$item]."</td>
            <td>".$aQty[$item]."</td>
            <td>".$aPrice[$item]*$aQty[$item]."</td>
            <td><a href='#' onclick='RemoveItem(\"Remove\",\"".$aModel[$item]."\")';>Remove Item</a></td>
            </tr>";
            }

            return $tableString;
            }

            L 1 Reply Last reply
            0
            • L LordLothar

              My bad, what I mean is, first I tried it in JavaScript (never mind about this). Since I use session in php thus I will loop my array and put it in DOM. I should try this before asking, below are example I have to create DOM in php. I will change the element name as html table later. What concern me this will also return string or xml format? to xhr.responseText, in the end I have to display this using innerHTML to tag id I have in my html page. Will that still work in IE?

              ECHO (toXml($myCart));

              function toXml($aCart)
              {
              $doc = new DomDocument('1.0');
              $cart = $doc->createElement('cart');
              $cart = $doc->appendChild($cart);

              foreach ($aCart as $Item => $ItemName)
              { 
              	$book = $doc->createElement('book');
              	$book = $cart->appendChild($book);
              	$title = $doc->createElement('title');
              	$title = $book->appendChild($title);
              	$value = $doc->createTextNode($Item);
              	$value = $title->appendChild($value);
              	$quantity = $doc->createElement('quantity');
              	$quantity = $book->appendChild($quantity);
              	$value2 = $doc->createTextNode($ItemName);
              	$value2 = $quantity->appendChild($value2);
              }
              

              $strXml = $doc->saveXML(); // this serializes the XML as a string
              return $strXml;
              }

              This is my previous post of php code that return string with element tr and td (which doesnt work in IE of course):

              function toHTML($aModel,$aMaker,$aPrice,$aQty)
              {
              $tableString="<tr>
              <th>Manufacturer</th>
              <th>Model</th>
              <th>Price</th>
              <th>Qty</th>
              <th>Total Price</th>
              </tr>";
              foreach ($aModel as $item)
              {
              $tableString .="<tr id='".$aModel[$item]."'>
              <td>".$aMaker[$item]."</td>
              <td>".$aModel[$item]."</td>
              <td>".$aPrice[$item]."</td>
              <td>".$aQty[$item]."</td>
              <td>".$aPrice[$item]*$aQty[$item]."</td>
              <td><a href='#' onclick='RemoveItem(\"Remove\",\"".$aModel[$item]."\")';>Remove Item</a></td>
              </tr>";
              }

              return $tableString;
              }

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              LordLothar wrote:

              What concern me this will also return string or xml format? to xhr.responseText, in the end I have to display this using innerHTML to tag id I have in my html page. Will that still work in IE?

              Sounds like you might be starting to catch on.

              led mike wrote:

              AFAIK, you have never been able to set the innerHTML of a TABLE element in IE.

              1 Reply Last reply
              0
              • L LordLothar

                I have response text of table string from php (including the tr and td )and I want to display it in my table with id= "displayCart" as follow:

                <table border=1 id="displayCart" ></table>

                document.getElementById("displayCart").innerHTML = xhr.responseText; It work in Firefox, but not in my IE7.

                R Offline
                R Offline
                Reelix
                wrote on last edited by
                #7

                The best I can think that works in both IE and Firefox is:

                <table border=1><tr><td id = "td1"></td></tr></table>

                Then

                javascript:void(document.getElementById('td1').innerHTML='Test2')

                Hope that helps. - Reelix

                -= Reelix =-

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups