473,796 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hiding Table Rows

I'm getting an error in displayDirector s() on the line shown. What I
want to do is hide the rows in the table where rs_Board("DirSt atus") =
"Retired" with hideDirectors() and show all records with
showDirectors() . What I did was create a column with a checkbox which
is not visible to the user and check this box when
rs_Board("DirSt atus") = "Retired" and leave it unchecked when it
doesn't. There's probably a better way of doing this. I also want the
text in <span id="DirectorsCa ption"> to change with each function but
I'm pretty sure this will work when the other error is debugged.
Thanks.

<table width="750">
<tbody id="DirectorsBo dy" class="smalltex t">

<tr>
<td align="center" valign="top" colspan="12"><s pan
id="DirectorsCa ption">ALL CURRENT AND RETIRED DIRECTORS</span></td>
</tr>

<tr>
<td align="center" width="1"></td>
</tr>

<!-- Begin Looping through the records in the rs_Board recordset -->

<tr>
<% Do While Not rs_Board.EOF %>
<td align="center" width="0">
<%
'Make the retired rows a shade of grey except for the IsCEO and
IsChairman columns
If rs_Board("DirSt atus") = "Retired" Then
strBgColor="#DB DBDB"
Response.Write "<input type=""checkbox ""
style=""display :none"" checked />"
Else
strBgColor="#FF FFFF"
Response.Write "<input type=""checkbox ""
style=""display :none"" />"
End If
%>
</td>
<%
rs_Board.MoveNe xt
Loop
%>

<tr>
<td><input type="button" value="Current directors only"
onclick="hideDi rectors();" />
<input type="button" value="All current and retired directors"
onclick="showDi rectors();" /></td>
</tr>

function displayDirector s(show) {
var elem = document.getEle mentById("Direc torsBody");
for (var i = elem.rows.lengt h-1; i >= 0 ; i--) {
if (elem.rows[i].cells[0].firstChild.che cked) { <----Error
here
elem.rows[i].style.display = show ? "inline" : "none";
}
}
}

function hideDirectors( ) {
displayDirector s(false);
document.getEle mentById("Direc torsCaption").i nnerHTML = "CURRENT
DIRECTORS";
}

function showDirectors( ) {
displayDirector s(true);
document.getEle mentById("Direc torsCaption").i nnerHTML = "ALL CURRENT
AND RETIRED DIRECTORS";
DIRECTORS";
}

Mar 11 '06 #1
1 2227
shankwheat wrote:
I'm getting an error in displayDirector s() on the line shown. What I
want to do is hide the rows in the table where rs_Board("DirSt atus") =
"Retired" with hideDirectors() and show all records with
showDirectors() . What I did was create a column with a checkbox which
is not visible to the user and check this box when
rs_Board("DirSt atus") = "Retired" and leave it unchecked when it
doesn't. There's probably a better way of doing this. I also want the
text in <span id="DirectorsCa ption"> to change with each function but
I'm pretty sure this will work when the other error is debugged.
Thanks.

<table width="750">
<tbody id="DirectorsBo dy" class="smalltex t">

<tr>
<td align="center" valign="top" colspan="12"><s pan
id="DirectorsCa ption">ALL CURRENT AND RETIRED DIRECTORS</span></td>
</tr>

<tr>
<td align="center" width="1"></td>
</tr>

<!-- Begin Looping through the records in the rs_Board recordset -->

<tr>
<% Do While Not rs_Board.EOF %>
<td align="center" width="0">
<%
'Make the retired rows a shade of grey except for the IsCEO and
IsChairman columns
If rs_Board("DirSt atus") = "Retired" Then
strBgColor="#DB DBDB"
Response.Write "<input type=""checkbox ""
style=""display :none"" checked />"
Else
strBgColor="#FF FFFF"
Response.Write "<input type=""checkbox ""
style=""display :none"" />"
End If
%>
</td>
<%
rs_Board.MoveNe xt
Loop
%>

<tr>
<td><input type="button" value="Current directors only"
onclick="hideDi rectors();" />
<input type="button" value="All current and retired directors"
onclick="showDi rectors();" /></td>
</tr>

function displayDirector s(show) {
var elem = document.getEle mentById("Direc torsBody");
for (var i = elem.rows.lengt h-1; i >= 0 ; i--) {
if (elem.rows[i].cells[0].firstChild.che cked) { <----Error


Well the checkbox is not the firstChild is it? There's a textNode as the
first child - you have whitespace after the <td>.

You need a getFirstElement () function which looks at firstChild, and
goes through nextSibling until the nodeType == 1 (1 being an element node)

Or you could use elem.rows[i].cells[0].getElementsByT agName("input")[0]

This seems all a bit heavy handed though. I'd experiment with using
styles. Have a "director" class in your stylesheet, and then modify it
in your hide/display function so that you could affect all rows with
that class in one hit instead of looping through them all.
Mar 12 '06 #2

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

Similar topics

1
8996
by: Rick Measham | last post by:
I have a set of data that I display in a table. Each row has a category and there may be a dozen or more rows in the same category. I'm looking to add filter buttons to the page to hide/show categories on the fly. Currently I can: Set the id on the tr to (category name) or to (category name.data id). Using the first, is there a way to hide all rows with that same id? It seems currently to only hide the first row with that id.
8
23998
by: F. Da Costa | last post by:
Following is a snippet of html in which I hide a whole table and try to hide a single row. Here is my question (plz don't chew my head off if its css related instead): Why does the divTable <div> Hide/Show work but not the divRow version? What I'm trying to do here is simultaneously hide 1 or more rows (possibly with nested divs as well). This would allow for an elegant an well performing base for an html base treetable (but I guess...
5
1551
by: mt | last post by:
In a nutshell, I'd like to have a list of items, each of which fills out a small table which displays some info about a particular item(the items being a trouble ticket for a tech support ASP-built web-based app). There may be zero, one, or many of these per ticket. Since some tickets have many of these items (call them work items), the page can get awful long. I have this part working already. So my proposed solution to make the pages...
1
553
by: luvdairish | last post by:
Can someone please look at my code and see why tables are not hiding properly? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Untitled Document</TITLE> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <SCRIPT type=text/javascript> <!--//
6
1378
by: luvdairish | last post by:
I tried posting a few times, but it hasn't shown up. Hope this one works. Problem: Having trouble hiding tables when page is loaded. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Untitled Document</TITLE> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
5
2173
by: Ben | last post by:
I have a form for data entry which is in a table. I have a select box to enter a customer name, which takes it's options from the customer database. I have a button to add a new customer. What I want is for the relevant customer fields to magically appear underneath the selelect box when the "add customer button" is pressed. For some reason my code is NOT working. Have been trying to do it with div tags and style sheets using a...
6
1994
by: Roy | last post by:
Since a datagrid is just an html table anyways, this seems like it should be easy but it's giving me a hard time. In ItemDataBound sub I'm trying to kick off javascript code using response.write(). The javascript code is contained within an IF block and if e.Item.Cells(0).Text = myVariable then the row gets hidden. A user can still view those rows later with a buttonclick. Only problem is, I aside from what I've described above, I...
1
1860
by: Fix_Metal | last post by:
Hello all. I'm new to this group :) I have a problem with javascript language. I'm making an .asp page with some integrated Javascript functions. The page consists of some HTML selects and a table. The table is obviously populated from a database :) so it is dynamic. The database contains a field containing some names. This field is not a PK, thus the names can be repeated very easily). I want the user to be able to see all the rows...
2
6715
by: Garg | last post by:
How do I hide a paricular tablerow during run time? I have two table rows with ids row1 and row2. I want that if a particualr condition is true, then row 1 should be displayed on the web page, otherwise row2 should be dispalyed. I tried following code, but it is not working: row1.Style.Value = "block" row2.Style.Value="None"
2
3623
by: chris f | last post by:
I have an ASP.NET 2 web page that dynamically populates an ASP table in the Page_Load event. Rows relate to different people and I want to let the user display only rows for a particular person when they select them from a dropdown list on the same page. (Each row has a hidden PersonId column.) The page initially shows the rows for all people. Is it possible to hide the rows for the other people when the user selects a person from the...
0
10453
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10223
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.