473,404 Members | 2,137 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,404 software developers and data experts.

table added to div doesn't appear when using IE

I am dynamically generating a table in IE to display some information.
I will probably change it to divs later, but I just want to get it
working properly first.

In my div I have the following as the value of innerHTML:
"<TABLE>
<TR>
<TD id=td6x vAlign=top align=right><IMG height=14 alt=Required
src=\"/images/ci/icons/required.gif\" width=7 border=0
vAlign=\"top\"><INPUT id=anchor6x width=0 size=10
readonly=\"readonly\"></TD>
<TD><A id=urlanchor6x href=\"#ignore6\"><IMG height=24
src=\"/images/ci/icons/calendar_s.gif\" width=24 border=0
vAlign=\"bottom\"></A></TD></TR></TABLE>"

But, when I exit the function that generated this, there is nothing
displayed in IE, for what I wanted added.
This is the innerHTML value for the parent of the div above:

"<A name=#ignore6></A>
<DIV id=datespan6 style=\"VISIBILITY: visible\" _extended=\"true\">
<TABLE>
<TR>
<TD id=td6x vAlign=top align=right><IMG height=14 alt=Required
src=\"/images/ci/icons/required.gif\" width=7 border=0
vAlign=\"top\"><INPUT id=anchor6x width=0 size=10
readonly=\"readonly\"></TD>
<TD><A id=urlanchor6x href=\"#ignore6\"><IMG height=24
src=\"/images/ci/icons/calendar_s.gif\" width=24 border=0
vAlign=\"bottom\"></A></TD></TR></TABLE></DIV><INPUT id=lda6x
type=hidden _extended=\"true\"> "

Everything works fine in Firefox 1.5, but not in IE.

This is the code that generated the table:
var anchorName = "anchor" + indx + "x";
var tdChildEl = document.createElement("td");
tdChildEl.align = "right";
tdChildEl.vAlign = "top";
tdChildEl.id = "td" + indx + "x";
var imgelem = document.createElement('img');
imgelem.src = "/images/ci/icons/required.gif";
imgelem.alt = "Required";
imgelem.vAlign = "top";
imgelem.border = "0";
imgelem.height = "14";
imgelem.width = "7";
tdChildEl.appendChild(imgelem);

var inputChildEl =
document.createElement("input");
inputChildEl.type = "text";
inputChildEl.name="date" + indx;
inputChildEl.value = $('lda' + indx +
'x').value;
inputChildEl.id = anchorName;
inputChildEl.onmouseout =
ModifyGrades.handlemouseout;
inputChildEl.onmouseover =
ModifyGrades.handlemouseover;
inputChildEl.onclick = ModifyGrades.dateSelect;
inputChildEl.width = "10em";
inputChildEl.size = 10;

inputChildEl.setAttribute("readonly","readonly");

tdChildEl.appendChild(inputChildEl);
var rowelem = document.createElement('tr');
rowelem.appendChild(tdChildEl);

var aChildEl = document.createElement("a");
aChildEl.href = "#ignore" + indx;
aChildEl.name = anchorName;
aChildEl.id = "url" + anchorName;
aChildEl.onclick = function(){
ModifyGrades.callCalendarIcon(document.forms[0]["date"+indx], "url" +
anchorName); return false; }
var calImgEl = document.createElement('img');
calImgEl.src =
"/images/ci/icons/calendar_s.gif";
calImgEl.vAlign = "bottom";
calImgEl.border = "0";
aChildEl.appendChild(calImgEl);
tdChildEl = document.createElement('td');
tdChildEl.appendChild(aChildEl);
rowelem.appendChild(tdChildEl);

var tableelem =
document.createElement('table');
tableelem.appendChild(rowelem);
span.appendChild(tableelem);
span.style.visibility="visible";

Any idea on what I might be doing wrong?

Thank you for any help.

Apr 27 '06 #1
1 2208
James Black said on 28/04/2006 3:25 AM AEST:
I am dynamically generating a table in IE to display some information.
I will probably change it to divs later, but I just want to get it
working properly first.

In my div I have the following as the value of innerHTML:
"<TABLE>
<TR>
<TD id=td6x vAlign=top align=right><IMG height=14 alt=Required
src=\"/images/ci/icons/required.gif\" width=7 border=0
vAlign=\"top\"><INPUT id=anchor6x width=0 size=10
readonly=\"readonly\"></TD>
<TD><A id=urlanchor6x href=\"#ignore6\"><IMG height=24
src=\"/images/ci/icons/calendar_s.gif\" width=24 border=0
vAlign=\"bottom\"></A></TD></TR></TABLE>"

But, when I exit the function that generated this, there is nothing
displayed in IE, for what I wanted added.
This is the innerHTML value for the parent of the div above:

"<A name=#ignore6></A>
<DIV id=datespan6 style=\"VISIBILITY: visible\" _extended=\"true\">
<TABLE>
<TR>
<TD id=td6x vAlign=top align=right><IMG height=14 alt=Required
src=\"/images/ci/icons/required.gif\" width=7 border=0
vAlign=\"top\"><INPUT id=anchor6x width=0 size=10
readonly=\"readonly\"></TD>
<TD><A id=urlanchor6x href=\"#ignore6\"><IMG height=24
src=\"/images/ci/icons/calendar_s.gif\" width=24 border=0
vAlign=\"bottom\"></A></TD></TR></TABLE></DIV><INPUT id=lda6x
type=hidden _extended=\"true\"> "

Everything works fine in Firefox 1.5, but not in IE.

This is the code that generated the table:
var anchorName = "anchor" + indx + "x";
When posting code, indent with 2 or 4 spaces, manually wrap at about 70
characters to prevent auto-wrapping introducing errors.

var tdChildEl = document.createElement("td");
tdChildEl.align = "right";
tdChildEl.vAlign = "top";
tdChildEl.id = "td" + indx + "x";
var imgelem = document.createElement('img');
imgelem.src = "/images/ci/icons/required.gif";
imgelem.alt = "Required";
imgelem.vAlign = "top";
imgelem.border = "0";
imgelem.height = "14";
imgelem.width = "7";
tdChildEl.appendChild(imgelem);

var inputChildEl =
document.createElement("input");
inputChildEl.type = "text";
inputChildEl.name="date" + indx;
inputChildEl.value = $('lda' + indx +
'x').value;
The use of $(...) indicates the use of prototype.js, it seems you don't
really need it here.

inputChildEl.id = anchorName;
inputChildEl.onmouseout =
ModifyGrades.handlemouseout;
inputChildEl.onmouseover =
ModifyGrades.handlemouseover;
inputChildEl.onclick = ModifyGrades.dateSelect;
inputChildEl.width = "10em";
inputChildEl.size = 10;
It's not a good idea to use deprecated element attributes, use CSS style
attributes instead.


inputChildEl.setAttribute("readonly","readonly");
A recent thread discussed setAttribute vs. direct access to DOM object
properties. Some browsers have issues with setAttribute, so just use:

inputChildEl.readonly = true;


tdChildEl.appendChild(inputChildEl);
var rowelem = document.createElement('tr');
1. Create the table here and then the row using:

var tableelem = document.createElement('table');
var rowelem = tableelem.insertRow(-1);
For reference:

<URL:http://developer.mozilla.org/en/docs/DOM:table.insertRow>
See below...

rowelem.appendChild(tdChildEl);

var aChildEl = document.createElement("a");
aChildEl.href = "#ignore" + indx;
aChildEl.name = anchorName;
aChildEl.id = "url" + anchorName;
aChildEl.onclick = function(){
ModifyGrades.callCalendarIcon(document.forms[0]["date"+indx], "url" +
anchorName); return false; }
var calImgEl = document.createElement('img');
calImgEl.src =
"/images/ci/icons/calendar_s.gif";
calImgEl.vAlign = "bottom";
Deprecated attributes again...

calImgEl.border = "0";
aChildEl.appendChild(calImgEl);
tdChildEl = document.createElement('td');
tdChildEl.appendChild(aChildEl);
rowelem.appendChild(tdChildEl);
More efficient replace the above 3 lines with:

var tdChildEl = rowelem.insertCell(-1);
tdChildEl.appendChild(aChildEl);

var tableelem =
document.createElement('table');
tableelem.appendChild(rowelem);
In IE you can't add rows directly to a table using appendChild, you must
add them to a tbody. To save creating a tbody, appending it, etc.
create the table and row as indicated at 1. above using insertRow.

span.appendChild(tableelem);
span.style.visibility="visible";


Where is 'span' defined? If it's a span, it can't have a table as a
child - the result of the above may be unpredictable.

There may be other errors, I haven't tested it.

--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
Apr 27 '06 #2

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

Similar topics

25
by: kie | last post by:
hello, i have a table that creates and deletes rows dynamically using createElement, appendChild, removeChild. when i have added the required amount of rows and input my data, i would like to...
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
1
by: ajay | last post by:
I have following code for a slide menu but i twiked it to work for a single level menu. Open it in a Browser to get a clear picture. I have 2 Qs 1) How to make first entry as non-link. i.e i...
47
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
7
by: Just Dummy | last post by:
Hi all, I am struggling with a problem for a long time. Problem statement: I have a table and the table can contain n number of rows. i.e., the table rows will be generataed out of a xml...
4
by: sheree | last post by:
I have 3 tables (amoung a few others) in a small access database. The tables are as follows: == AEReport -------- AEID (PK) RptCatelog GCRCID PatientID EvntDate
2
by: JohnR | last post by:
I have a table in a dataset whose fields are bound to various controls on my form. The records are sorted by primary key so when I use the currencymanager to navigate the data, it all appears...
2
by: James Black | last post by:
I am dynamically generating a table in IE to display some information. I will probably change it to divs later, but I just want to get it working properly first. In my div I have the following...
6
by: azegurb | last post by:
Hello, I have one question again i created one table again and in this table i added some another options for ex at the previous table there were only one problem sum of the dynamically added...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.