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

Works in IE but not in FF - Please Help

I have multiple rows in a table that I can toggle their visibility in IE 6 using the function below. However, this does not work in FF 2.x. I can't use getElementById() because I need to identify multiple <TR> tags in the document.

Can someone please show me how to recode this function below to work in both browsers. TIA.

function hideEmptyFields_ff()
{
var oLink = document.getElementById('hidelink')
//var oImages = document.getElementsByTagName('TR');
var oRows = document.all || document.getElementsByTagName('TR');

if (oRows.length)
{
for (var i = 0; i < oRows.length; i++)
{
var oRow = oRows[i]
if (oRow.name == 'emptyrow')
{
if (oRow.style.display == 'none')
{
oRow.style.display = '';
oLink.innerHTML = 'Hide Empty Fields'
}
else
{
oRow.style.display = 'none';
oLink.innerHTML = 'Show Empty Fields'
}
}
}
}
}
Mar 29 '07 #1
3 1569
acoder
16,027 Expert Mod 8TB
What's the default style setting for the rows?
Mar 29 '07 #2
Not sure what you mean by default setting for the rows. I can tell you that the rows in the table I want to hide are given the following attribute:

name='hiderow'

These are rows that represent empty fields from my data source so I am giving the user an option to hide these empty rows.

Most examples providing an alternative to IE's document.all suggest using getElementById() but this only works for single object in the DOM. Since I want to find multiple rows, I used the name attribute instead where I can have multiple objects with the same name. So I needed to use getElementsByTagName() (notice the plurality of elements in the name) to get a collection of all the rows with this attribute.

After researching the getElementsByTagName(), I was able to construct an alternate function that appears to work in both IE 6 and FF 2.x and is shown below. It appears that assigning an single a single object in the collection to a new variable does not work in FF although this appears like a standard OO contruct. Or maybe I just missed something simple.

var oRow = oRows(iImg);

Here it function that works in both IE 6 and FF 2.x:

function hideEmptyFields_ff()
{
var oLink = document.getElementById('hidelink')
//var oImages = document.getElementsByTagName('TR');
var oRows = document.all || document.getElementsByTagName('TR');

for (var i = 0; i < oRows.length; i++)
{
n = oRows[i].getAttribute("name");
if (n == 'emptyrow')
{
if (oRows[i].style.display == 'none')
{
oRows[i].style.display = '';
oLink.innerHTML = 'Hide Empty Fields'
}
else
{
oRows[i].style.display = 'none';
oLink.innerHTML = 'Show Empty Fields'

}
}
}
}

Does anyone see a problem with this code?

I did see an example where the table is and ID and getElementById() is used to first get a reference to the table and then the table reference is used to get all ('TR') tags. I guess this might improve speed since the initial collection is limited to the table to locate the rows. Perhaps I will try this and post again if the difference it worth noting. TIA.


Finally, an interesting observation is that I can call this function from the <Body> tag's onload event so that the "named" rows are actually hidden before the page first displays. IE 6 instantly displays the page with the rows already hidden while FF displays the page with rows as visible and then after a fraction of second, the rows are hidden which is not desirable. FF apparently displays the page and then runs the function to hide the rows after the fact. I am trying to like FF but in this case, IE 6 appears to handle this in a superior way. Is there a way to have FF not display the page until the rows are hidden?
Mar 29 '07 #3
iam_clint
1,208 Expert 1GB
var oRows = document.getElementsByTagName('TR');
Mar 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: SÁRINGER Zoltán | last post by:
Hello! I have an ASP page using Jet 4.0 oldeb provider for mdb. (ADO 2.8). I use the _same_ code in ASP from my well working VB application. The problem is: when I do the same "SELECT * FROM...
5
by: gabbott | last post by:
I've designed a very simple VB.NET project that uses the .NET framework functionality to access registry keys. At the moment it pulls values from a few keys and puts them into a listbox. The...
2
by: James Zhuo | last post by:
Accessing Items in a Collection works with the as suggested by Kevin and Chris (thx) But when i tried to use the same technic with databinding within the aspx file, it doesn't seem to work. This...
6
by: goober | last post by:
Ladies & Gentlemen: I have built a form that client-side validates and posts data to a CRM beautifully in Internet Explorer (IE) 6. The problem comes in FireFox (FF) 1.5 when everything works...
10
by: Smurff | last post by:
Hi, This code works fine on win and linux but not on hpux. All is compiled with gcc. Can anyone help please? /*****************************************************************************/ /*...
1
by: Ethan Strauss | last post by:
Hi, I have a C#.net Web application which calls a web service (http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/eutils.wsdl). It has run just fine for months. Recently I started getting...
9
by: Dave | last post by:
Hi, I've been trawling the web for answer to my problem with no luck although I'm hardly alone it seems! Below is the generated source for an ASP page that posts a value called 'album' to...
8
by: John Austin | last post by:
I need to understand why if I add a control and use AddHandler to connect its click event, it will work in Page_Load, but not in a Button_Click. The idea is that the user types some data, presses...
8
by: Brett | last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a different box from the web server) and displays the result in a GridView. The datasource for the GridView is a SQLDataSource....
1
by: =?Utf-8?B?amVubmlmZXI=?= | last post by:
Im sure this question has been asked but I cant seem to find an answer I understand. I have works 9 on vista. Everytime I try to open an attachment or send a document from it I get an error. I have...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.