IE: innerHTML to table id
-
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. -
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.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. -
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.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?
-
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?
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.
-
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.
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;
} -
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;
}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.
-
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.