473,395 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

innertext - unknown runtime error

like below approach i need to add bulk of data in innertext, but for
this simple case itself it is giving error, i badly need this approch
and i failed with search also , so pl give me a soln asap, thanx in
advance for spending ur time for me

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<script language=javascript>
function test()
{
alert(document.getElementById('tbd1').innerHTML);
document.getElementById('tbd1').innerHTML+='<tr><t d>EFG</td></tr>';
}
</script>
<body>
<table id='tbl1'>
<tbody id='tbd1'>
<tr>
<td onmouseover=test() >
ABC
</td>
</tr>
</tbody>
</table>
</body>
</html>

Nov 23 '05 #1
8 24797
su***************@gmail.com said the following on 11/21/2005 2:50 AM:
like below approach i need to add bulk of data in innertext, but for
this simple case itself it is giving error, i badly need this approch
and i failed with search also , so pl give me a soln asap, thanx in
advance for spending ur time for me


There is no use of innerText in your page. I assume you are referring to
innerHTML instead since that is what you are using. IE doesn't like you
attempting to change the innerHTML of a tbody. Either change the table's
innerHTML or use DOM2 methods to create new elements and then append
them to the table.

It doesn't throw an error in Firefox but it doesn't do what you intended
either.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 23 '05 #2
su***************@gmail.com wrote:
like below approach i need to add bulk of data in innertext, but for
this simple case itself it is giving error, i badly need this approch
and i failed with search also , so pl give me a soln asap, thanx in
advance for spending ur time for me


What Randy said, plus Microsoft say in their documentation don't use
innerHTML to modify tbody, tr, th or td elements, use DOM (they actually
refer to a 'table object model', but DOM is a better bet).

If you are going to use innerHTML near a table, write the entire table
or just cell content, no in between.
--
Rob
Nov 23 '05 #3


Thanks for ur replies, Sorry, in my subject i wrongly mentioned as
innertext instead of InnerHTML and i tried with table also, that also
throwing the same error (i am using IE 6) and eventhough i did not add
the tbody it is automatically adding table body, ie. y i added myself.
so i try with createElement

<script language=javascript>
function test()
{
alert(document.getElementById('tbl1').innerHTML);
document.getElementById('tbl1').innerHTML+='<tr><t d>EFG</td></tr>';

}
</script>
<body>
<table id='tbl1'>
<tr>
<td onmouseover=test() >
ABC
</td>
</tr>
</table>
</body>
</html>

Nov 23 '05 #4
VK
You cannot manipulate table structure over innerHTML.

Overall you are very rarely able to manipulate document DOM using
innerHTML.

This method is cross-browser reliable only for sample things like
setting rich-formatted HTML content to an existing element (like table
cell, div, span etc.)

In your case you have to use the table manipulation mechanics by W3C or
by IE-exclusive way. Description and comparison of both please see
here:

<http://msdn.microsoft.com/workshop/author/tables/buildtables.asp>

Nov 23 '05 #5
su***************@gmail.com wrote:

Thanks for ur replies, Sorry, in my subject i wrongly mentioned as
innertext instead of InnerHTML and i tried with table also, that also
throwing the same error (i am using IE 6) and eventhough i did not add
the tbody it is automatically adding table body, ie. y i added myself.
A tbody element is mandatory even though the tags are optional.
Browsers will add a tbody element where it is needed.

so i try with createElement

<script language=javascript>
The language attribute is deprecated, type is required:

<script type="text/javascript">

function test()
{
alert(document.getElementById('tbl1').innerHTML);
document.getElementById('tbl1').innerHTML+='<tr><t d>EFG</td></tr>';
Replace the above line with:

if (!document.getElementById || !document.createElement) return;
var row = document.getElementById('tbl1').insertRow(-1);
var cell = document.createElement('td');
cell.appendChild(document.createTextNode('EFG'));
row.appendChild(cell);

}
</script>
<body>
<table id='tbl1'>
<tr>
<td onmouseover=test() >
ABC
</td>
</tr>
</table>
</body>
</html>

--
Rob
Nov 23 '05 #6
Hi all

In above style i created the element, if i try to assign css class for
that it is bugging , y

lbl=document.createElement('LABEL');
lbl.innerText='ABC';
lbl.id='lblid';
lbl.class='bold11';

Nov 23 '05 #7
i got the soln, ie className

Nov 23 '05 #8
su***************@gmail.com wrote:
In above style i created the element, if i try to assign css class for
that it is bugging , y

lbl=document.createElement('LABEL');
lbl.innerText='ABC';

^^^^^^^^^
This is IE only. You are mixing features of different DOMs (above:
W3C DOM; here: IE DOM) without feature test which is a Bad Thing.
You should write instead _at least_

var txt = document.createTextNode('ABC');
lbl.appendChild(txt);

<URL:http://www.pointedears.de/scripts/test/whatami>
PointedEars
Nov 23 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ivan Debono | last post by:
Hi, I keep getting an Unknown runtime error on line 3 below: 1 If oField.Type <> 136 Then 'adChapter 2 If Right(oField.name, 3) = "_id" Then 3 For Each...
2
by: delraydog | last post by:
I know that innerText is not supported in FireFox and I've found the following code fragment which was originally designed in an HTMLElement prototype for an innerText getter. I do not however want...
5
by: Lars-Erik Aabech | last post by:
Hi! Guess it's my day again.. Tried to deploy a test release of a new asp.net web today, and got a terrible error. The web is running swell on three development computers, but when it's copied...
22
by: José Teixeira Junior | last post by:
Hi, How i can add one new unknown control at runtime in my form1? Thaks.
10
by: rwalrus | last post by:
Getting an "unknown runtime error code 0" in IE6 on the last two lines of the function below. Works fine in Firefox 1.5, I can't figure out what IE is complaining about. Both "subtotal" and...
7
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement...
1
by: sasikumarks | last post by:
Hi, Im using the following code to retrieve the user details from the AD server. But when i execute the code,it throws me the error. Please help me in this...
21
by: sheldonlg | last post by:
I have googled for '"Internet Explorer" "Unknown runtime error"' and not found anything useful. I have the following (for simplicity of presentation here): <div><table><tr><th...
3
by: vp.softverm | last post by:
hi all in the follwing part of code am getting the unknown runtime error at <select> any help .......................................... Org.getCategories({callback:function(cat) { var...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.