473,386 Members | 1,803 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,386 software developers and data experts.

Mozilla, innerHTML question.

Here is some code I have bastardised from a few places, Obviously the
innerHTML coding won't work in Mozilla, could anyone suggest a work
around or fix?

cheers,
Mitch.
****************snip*************************
<html>
<head>
<title>Untitled</title>
<script>
var rowNum = 0;
function addRow(rowCount){
var theTab = document.getElementById('accTab');
var blankRow = theTab.rows[0];
for(r=0;r<rowCount;r++){
var newRow = theTab.insertRow();
for (i=0; i < blankRow.cols; i++) {

newRow.insertCell().innerHTML =
blankRow.cells[i].innerHTML.replace(/\#/g, rowNum++);

}
}

}
</script>
</head>
<body onLoad='addRow(5);'>
<table cellpadding="0" cellspacing="0" width="100%" id="accTab"
border="1">
<tr style="display:none" class="altRow" cols=6>
<td align="center"><input maxlength="20" size="13"
name="c_code1" ></td>
<td align="center"><select name=duty1><option value=""
rate="">Please select</option></select></td>
<td align="center"><input maxlength="4" size="2" ></td>
<td align="center"><input maxlength="4" size="2" ></td>
<td align="center"><input maxlength="8" size="5" ></td>
<td align="center"><input maxlength="8" size="7" ></td>
</tr>
<tr>
<th align="left">field1<span class="requiredField">*</span></th>
<th align="left">select1 <span class="requiredField">*</span></th>
<th align="left">field2<span class="requiredField">*</span></th>
<th align="left">field3<span class="requiredField">*</span></th>
<th align="left">field4</th>
<th align="left">field5</th>
</tr>
</table>
<table cellpadding="0" cellspacing="0" width="100%" border="1">
<tr>
<td colspan="6"><input type=button value='Add Item'
onClick="addRow(1)"></td>
</tr>
</table>
</body>
</html>
*********************************snip************* ***************
Jul 20 '05 #1
4 4999
DU
Mitch wrote:
Here is some code I have bastardised from a few places, Obviously the
innerHTML coding won't work in Mozilla, could anyone suggest a work
around or fix?

Your HTML markup code first need several fixes.
cheers,
Mitch.
****************snip*************************
<html>
<head>
<title>Untitled</title>
<script>
var rowNum = 0;
function addRow(rowCount){
var theTab = document.getElementById('accTab');
var blankRow = theTab.rows[0];
for(r=0;r<rowCount;r++){
var newRow = theTab.insertRow();
I believe this won't work. insertRow needs a parameter.
"index of type long
The row number where to insert a new row. This index starts from 0
and is relative to the logical order (not document order) of all the
rows contained inside the table."
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-39872903

Also, creating several rows in a for loop won't work in MSIE 6.
for (i=0; i < blankRow.cols; i++)
cols is not a valid attribute of an referenced table row. cells.length
is though.
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-67349879

for(var CellIterator = 0; CellIterator < blankRow.cells.length;
CellIterator++)
would be ok though.

{
newRow.insertCell().innerHTML =
blankRow.cells[i].innerHTML.replace(/\#/g, rowNum++);
Same thing here. insertCell() needs a parameter and only once the
returned value has been achieved into another objRefCell, then you can
"edit" the content of that cell accordingly.

var objTCell = newRow.insertCell(i);
if(objTCell.tagName == "TD") {objTCell.firstChild.nodeValue = "text node
value";};
or
if(objTCell.nodeType == 1) {objTCell.firstChild.nodeValue = "text node
value";};

"index of type long
The place to insert the cell, starting from 0."
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-68927016

}
}

}
</script>
</head>
<body onLoad='addRow(5);'>
<table cellpadding="0" cellspacing="0" width="100%" id="accTab"
border="1">
<tr style="display:none" class="altRow" cols=6>

cols=6 is invalid html.

<td align="center"><input maxlength="20" size="13"
name="c_code1" ></td>
<td align="center"><select name=duty1><option value=""
rate="">

1- rate="" is an invalid html attribute.
2- select can not exist without a wrapping form element.
Please select</option></select></td> <td align="center"><input maxlength="4" size="2" ></td>
<td align="center"><input maxlength="4" size="2" ></td>
<td align="center"><input maxlength="8" size="5" ></td>
<td align="center"><input maxlength="8" size="7" ></td>
</tr>
<tr>
<th align="left">field1<span class="requiredField">*</span></th>
<th align="left">select1 <span class="requiredField">*</span></th>
<th align="left">field2<span class="requiredField">*</span></th>
<th align="left">field3<span class="requiredField">*</span></th>
<th align="left">field4</th>
<th align="left">field5</th>
</tr>
</table>
<table cellpadding="0" cellspacing="0" width="100%" border="1">
<tr>
<td colspan="6"><input type=button value='Add Item'
onClick="addRow(1)"></td>
</tr>
</table>
</body>
</html>
*********************************snip************* ***************


You should validate your document ( http://validator.w3.org/ ): DOM2
HTML methods work best when the document markup syntax is perfectly valid.

Working example in Mozilla-based browsers, MSIE 6 for Windows, Opera 7.x:
Dynamically creating, populating and inserting a table
http://www10.brinkster.com/doctorunc...tingTable.html

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #2
Thanks for the reply but I have already fixed the problem, Turns out
Mozilla doesn't like insertCell().

BTW the stuff you have pointed out as HTML errors are either being used
or generated by other parts of my app.

Should I post the entire page next time? or just the information
pointent to the question?
Mitch.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
DU
mitchel Turner wrote:
Thanks for the reply but I have already fixed the problem, Turns out
Mozilla doesn't like insertCell().

That is not my conclusion. In some specific context, insertCell(index)
will not work in MSIE 6 for Windows but, as far as I can see,
insertCell(index) will always work accordingly in Mozilla.
BTW the stuff you have pointed out as HTML errors are either being used
or generated by other parts of my app.

Should I post the entire page next time? or just the information
pointent to the question?
Mitch.


An url is always better, more convenient.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #4
JRS: In article <bk**********@news.eusc.inter.net>, seen in
news:comp.lang.javascript, DU <dr*******@hot-R-E-M-O-V-E-mail.com>
posted at Tue, 16 Sep 2003 22:25:19 :-
mitchel Turner wrote:
Should I post the entire page next time? or just the information
pointent to the question?

An url is always better, more convenient.
Not so. It is not convenient for those who read News off-line.

What is best is for the questioner is to develop a minimum example of
the problem, or to remove extraneous parts from the page which has the
problem, testing at each step (that often reveals the answer). Once the
problem is localised, then if what remains is reasonably small it can be
posted here for all to see and otherwise its URL can be given.

That is as stated in the FAQ, more or less.
DU
--


DSS.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #5

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

Similar topics

10
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script...
1
by: Ted Weatherly | last post by:
Hello, I want to dynamically create a table cell with a textfield in it. The value for the textfield can have quotes. e.g. I have this snippet of javascript code: var td =...
6
by: Red_Indian | last post by:
Hi How do I accomplish the following functionality in Mozilla/ Firefox: document.form.textbox.disabled = false if I want to conditionally enable a text box that was disabled by default. ...
6
by: hsomob1999 | last post by:
so i have a <ul> and I allow the user to append items to it. The problem is that on mozilla the <span class="line"> which is just a line to divide the sections gets overlaped and doesnt move down...
8
by: Clément | last post by:
Hi! I am currently developping a user interface with Ajax/C#/.net. And I am facing a problem with Mozilla, and Firefox. I use the function innerHTML to load a Web UserControl into a div, this...
8
by: bennett.matthew | last post by:
Hello all, This is probably an elementary (no pun intended) question, but I've spent all afternoon on it and it's driving me crazy. I have a function which dynamically adds to a table. It...
2
by: mypublicmail | last post by:
I'm moving big chunks of html into and out of divs using innerHTML. Or, I thought I was until I tested it on Firefox 1.5. Firefox will move the html just fine, but if you have changed any input...
2
by: Jonny B | last post by:
Hi all, I'm working on an a clientside xslt using jscript that passes a parameter to the xsl. I've got it working no problem in IE but cant get it to work in Mozilla. Can anyone help? This is...
4
by: theaj | last post by:
Hi all, im trying to change the CSS of an HTML element dynamically...for that purpose im taking help of innerHTML property. i have made the text on which CSS gets applied dynamically, editable,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.