473,395 Members | 1,386 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.

Showing/Hiding <tr> s

Hi All -

I have some problems getting a small piece of javascript working
correctly for Firefox. Here is what I am trying to do -

1. I have a form (like a search form)
2. I have many groups of searchable fields in the fields
3. Each group can be expanded/collapsed by clicking on a link
"(Fewer|More) Options" which sits right next to the group title.

For eg. -
I can search a person on "Name" - this group, "Name" has one field,
"First Name" in the collapsed state and more searchable fields ("Last
Name", "Middle Name") in the expanded state.

To achieve this, what I did was -

1. All the fields in one table
2. One row for each Label/Text-Box pair
3. Two columns on each row, the left one for Label and the right one
for Text-Box

For collapsing/expanding purposes, I had assigned an ID to each <tr>
that can be hidden/shown. And I had used the following js functions for
doing the same -

function toggleFields() {
var i = 0;
var src = document.getElementById(arguments[0]);
if (src.state == null || src.state == 'more') {
src.state = 'few';
src.innerHTML = 'Fewer Options';
}
else {
src.state = 'more';
src.innerHTML = 'More Options';
}
for (i = 1; i < arguments.length; i++) {
var obj = document.getElementById(arguments[i]);
if (obj.showing == null || obj.showing == 1) {
obj.showing = 0;
}
else {
obj.showing = 1;
}
displayObject(arguments[i], obj.showing);
}
}
function displayObject(id, show) {
var obj = document.getElementById(id);
if (obj==null) return;
obj.style.display = show ? 'block' : 'none';
obj.style.visibility = show ? 'visible' : 'hidden';
}
The HTML is something like this -
<table>
<tr id="fname"> <td> ... </td> <td> ... </td> </tr>
<tr id="lname"> <td> ... </td> <td> ... </td> </tr>
<tr id="mname"> <td> ... </td> <td> ... </td> </tr>
</table>

And the link to expand/collapse this group is like this -
<a id="nameToggle" href="toggleFields('nameToggle', 'lname', 'mname')">
Fewer Options </a>

The problem that I am facing -
1. It works well in IE-6.0
2. Goofs up the UI in Firefox-1.0.4 -
Works well the first time, (i.e., hiding lname and mname), but when
trying
to expand the group again, the arrangement of rows/columns goes
amiss.

Is there something that I am doing wrong?

Thanks
- Anand

Aug 23 '05 #1
2 2187
c.**********@gmail.com wrote:
obj.style.display = show ? 'block' : 'none'; 2. Goofs up the UI in Firefox-1.0.4 -


In CSS 2 browsers, <tr> elements have a default display of table-row, not
block. Toggle between "none" and "" instead.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Aug 23 '05 #2

David Dorward wrote:

In CSS 2 browsers, <tr> elements have a default display of table-row, not
block. Toggle between "none" and "" instead.


Great! It works well now.
Thanks for your help
- Anand

Aug 23 '05 #3

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

Similar topics

2
by: John Geddes | last post by:
In both IE6 and Netscape 7: insertRow method of tbody is behaving as expected: - inserts a new row - increases tbody.rows.length BUT deleteRow is not doing the opposite. It DOES delete the...
7
by: F. Da Costa | last post by:
Hi, I' looking to retrieve ProdName1 form the <tr> below. <tr id="1-1-1" class="even"> <td> <div class="tier4"> <a href="#" class="leaf"></a> ProdName1 </div>
4
by: El Diablo | last post by:
Hi there, I'm trying dynamically generate extra rows in a table. So far this achieves this task within the tHead segment: theTable.tHead.appendChild(document.createElement('TR')) ....but...
4
by: Dominic | last post by:
I'm looking for a HTML editor that can match the opening and closing HTML tags such as <TR> </TR>, <TD> </TD> I think Dreamweaver does that, right? Even if it does, it may be too expensive for...
1
by: prefersgolfing | last post by:
I'm not using Master Pages, yet I'd like to display the contents of an HTML page within a <table><tr><td> on a .aspx. I have a lengthy guide already paginated in html. I'd like to embed the...
2
by: petereffect | last post by:
i have foll. code <tr> <a href="a1.shtml"> <td width='100%'> &nbsp;"+Testing+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td> </a>
5
by: mahesr | last post by:
I want to match some particular text between <tr>and </tr> or <td>and </td>.... in PHP. like below............ <table><tr> CATEGORY: <td><font face="Verdana" size="1" color="#A000A0"> Wedding...
3
by: jack | last post by:
Hi all im Creating a report in HTML with the help of dotnet.. im creating a which shows a data of 12 months .. the forst row of the column contains month names.. and the following data.. The...
7
by: Xiaoyan | last post by:
Hi,everyone: I have a problem now. I can't get the information between the <tr><td> and </td></tr>. for example: I use this regular expression can't get it, I don't know why....
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:
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: 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
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...
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
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.