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

Alternative for insertRow and insertCell, which is are supports in Firefox


Hi,
I have a problem with FireFox. I have written a function to Add rows
without submiting the form. This function works fine in IE, but not in
FireFox.
The function is :

function
createRows(deviceId,deviceType,modelName,ipAddress ,macAddress,imageURL)

{
oTable=document.getElementById("tab:tabForm:oTable ");

var oRow1=oTable.insertRow(oTable.rows.length);
var aRows=oTable.rows;
var aCells=oRow1.cells;
var oCell1_1=aRows(oRow1.rowIndex).insertCell(aCells.l ength);
var oCell1_2=aRows(oRow1.rowIndex).insertCell(aCells.l ength);
var oCell1_3=aRows(oRow1.rowIndex).insertCell(aCells.l ength);
var oCell1_4=aRows(oRow1.rowIndex).insertCell(aCells.l ength);
var oCell1_5=aRows(oRow1.rowIndex).insertCell(aCells.l ength);
var oCell1_6=aRows(oRow1.rowIndex).insertCell(aCells.l ength);

oCell1_1.innerHTML="<input>";
oCell1_2.innerHTML="";
oCell1_3.innerHTML="<font>"+modelName+"</font>";
oCell1_4.innerHTML="<font>"+ipAddress+"</font>";
oCell1_5.innerHTML="<font>"+macAddress+"</font>";
oCell1_6.innerHTML="<input>";
}
Can anyone please tell me what's the feature that is not supported in
Firefox that makes this function not work in the same.

Regards,
Raju

Jan 17 '07 #1
1 15757

ra******@gmail.com wrote:
Hi,
I have a problem with FireFox. I have written a function to Add rows
without submiting the form. This function works fine in IE, but not in
FireFox.
It's rarely useful to say "it doesn't work" without saying what "works"
is. The insertRow and insertCell methods of Firefox work according to
the W3C DOM Level 2 HTML Specifiction, there are no issues as far as I
know. In this case, IE is allowing you to have what would otherwise be
syntax errors in your code.

The function is :

function
createRows(deviceId,deviceType,modelName,ipAddress ,macAddress,imageURL)

{
oTable=document.getElementById("tab:tabForm:oTable ");

var oRow1=oTable.insertRow(oTable.rows.length);
If you want to insert a new row at the end of the current set of rows,
use:

var oRow1 = oTable.insertRow(-1);
var aRows=oTable.rows;
var aCells=oRow1.cells;
var oCell1_1=aRows(oRow1.rowIndex).insertCell(aCells.l ength);
In Firefox, your error message at this point should have been something
like "aRows is not a function". That is because it isn't, but you are
trying to use it as one. In many cases related to DOM objects, IE
doesn't distinguish between () and [], consequently it treats aRows(i)
as equivalent to aRows[i]. Firefox is ECMAScript compliant, and ()
will cause it to try and execute aRows, not find its ith element.

Fix the syntax error and it "works".

In any case, to add a cell to the end of oRow1, do it directly:

var oCell1_1 = oRow1.insertCell(-1);

Similarly for the rest of your cells. Incidentally, IE will allow you
to use no index for the inserted row, that will cause an error in other
browsers. The index parameter is required by the specification.

<URL: http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-68927016 >

[...]
oCell1_1.innerHTML="<input>";
An input element with only default attributes is pretty useless. What
is the intention here?

oCell1_2.innerHTML="";
There doesn't seem much point in setting the innerHTML property of a
newly created TD element to an empty string: it does nothing useful as
far as I know.
oCell1_3.innerHTML="<font>"+modelName+"</font>";
The font element is deprecated. What are you trying to achieve by
putting a string inside a font element with no defined attributes?
oCell1_4.innerHTML="<font>"+ipAddress+"</font>";
oCell1_5.innerHTML="<font>"+macAddress+"</font>";
oCell1_6.innerHTML="<input>";
Another default input element - what's the point?
--
Rob

Jan 17 '07 #2

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

Similar topics

3
by: Marco Alting | last post by:
Hi I'm currently developing a form with a dynamic table. initially the table is populated with data and at the end of each row there are two buttons: addLevel and addItem. Each button creates a...
3
by: milkyway | last post by:
Hello, I am working with an old Java Script code and have found the following but after putting in alerts I have found that insertRow doesn't work. What is the problem? TIA function...
1
by: putty | last post by:
I found a few posts of people asking about insertCell()/insertRow() not working in IE6 SP2, and a few others about getting "null is null or not an object" errors, but no one posted a solution...
7
by: steveneill | last post by:
Is this an alternative to eval(). Admittidly, I have done *very* little testing (ran it a few times in Firefox), but it seemed to work suprisingly well with simple expressions such as...
2
by: Howard Jess | last post by:
CLJ -- I've searched the newsgroup and FAQ for info on insertRow(), but didn't see this reported. It seems that Internet Explorer doesn't respond correctly to either insertRow() or...
10
by: Angel | last post by:
I have the following code var thisDoc=document.getElementById("myTable"); // myTable is the name of the table alert(thisDoc.childNodes.children.length) How do I change the second line of code...
3
by: edencane | last post by:
Hi. I've created a page that dynamically adds rows to a table. When I submit the page the request parameters of the dynamically generated rows don't get passed to the server. What is wrong?...
7
by: =?iso-8859-1?q?Jesper_R=F8nn-Jensen?= | last post by:
Hi. I just ran into a situation where I want to emulate the IE specific obj.click() syntax on an object on the webpage. The most convenient thing for me is if I were able to just select my ...
3
by: DL | last post by:
Here's the thing, I have this HTML Table, that has multile rows already, each has an ID, one of them at the bottom section has id of "SaveData", new TRs are dynamically created upon user...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...

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.