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

Deleting cells by name instead of index?

Hi,

I have a table where I am altering the layout via javascript to create
colspans. I want to then delete the "Extra" cells created by the
colspans.

I have named the cells "r1c1", "r1c2", "r2c1", etc..

document.getElementById('r2c2').colSpan="4"
cellRows = document.getElementById('tableChart').rows(1);
cellRows.deleteCell(2);
cellRows.deleteCell(2);
cellRows.deleteCell(2);

document.getElementById('r2c7').colSpan="4"
cellRows = document.getElementById('tableChart').rows(1);
cellRows.deleteCell(4);
cellRows.deleteCell(4);
cellRows.deleteCell(4);

This code works because when I'm working on r2c7, I know that I've
already deleted three cells above and so the next cells to delete are
column index of 4.. but what I'd like to be able to do is delete the
cells by name, in this case
'r2c8', 'r2c9', and 'r2c10'

Is there anyway to do that? I tried just

document.getElementById('r2c8').deleteCell()

but that gave me a javascript error..

Thanks,

Rich
Jul 23 '05 #1
6 3190
not certain but it seems as though deleteCell() may be a method of a
*row* object so have you tried

document.getElementById('r2c8').parentElement.dele teCell();

Tim

"Rich Morey" <rw*****@27east.com> wrote in message
news:f6**************************@posting.google.c om...
Hi,

I have a table where I am altering the layout via javascript to create colspans. I want to then delete the "Extra" cells created by the
colspans.

I have named the cells "r1c1", "r1c2", "r2c1", etc..

document.getElementById('r2c2').colSpan="4"
cellRows = document.getElementById('tableChart').rows(1);
cellRows.deleteCell(2);
cellRows.deleteCell(2);
cellRows.deleteCell(2);

document.getElementById('r2c7').colSpan="4"
cellRows = document.getElementById('tableChart').rows(1);
cellRows.deleteCell(4);
cellRows.deleteCell(4);
cellRows.deleteCell(4);

This code works because when I'm working on r2c7, I know that I've
already deleted three cells above and so the next cells to delete are column index of 4.. but what I'd like to be able to do is delete the
cells by name, in this case
'r2c8', 'r2c9', and 'r2c10'

Is there anyway to do that? I tried just

document.getElementById('r2c8').deleteCell()

but that gave me a javascript error..

Thanks,

Rich

Jul 23 '05 #2
"Tim Williams" <sa************@THISpacbell.net> wrote in message news:<2v*******************@newssvr25.news.prodigy .com>...
not certain but it seems as though deleteCell() may be a method of a
*row* object so have you tried

document.getElementById('r2c8').parentElement.dele teCell();

Tim


No, but I will..

Thanks for the idea..

Rich
Jul 23 '05 #3
"Tim Williams" <sa************@THISpacbell.net> wrote in message news:<2v*******************@newssvr25.news.prodigy .com>...
not certain but it seems as though deleteCell() may be a method of a
*row* object so have you tried

document.getElementById('r2c8').parentElement.dele teCell();

Tim

That worked!!! Thanks sooo much!!

:-)

Rich
Jul 23 '05 #4
"Tim Williams" <sa************@THISpacbell.net> wrote in message news:<2v*******************@newssvr25.news.prodigy .com>...
not certain but it seems as though deleteCell() may be a method of a
*row* object so have you tried

document.getElementById('r2c8').parentElement.dele teCell();


Okay, scratch that.. it didn't work.. Its just deleting the last cell
in the row, because the parent element of the cell is the row and
calling the deleteCell() without a variable deletes the last cell in
the row.

Rich
Jul 23 '05 #5
rw*****@27east.com (Rich Morey) writes:
Okay, scratch that.. it didn't work.. Its just deleting the last cell
in the row, because the parent element of the cell is the row and
calling the deleteCell() without a variable deletes the last cell in
the row.


Then use:
---
var cell = document.getElementById('r2c8');
cell.parentElement.deleteCell(cell.cellIndex);
---

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #6
>
Then use:
---
var cell = document.getElementById('r2c8');
cell.parentElement.deleteCell(cell.cellIndex);
---


Okay, I will give that a try.. I did actually write my own function to
get the index of the cell in the array of cells in the row element.. I
did not know that the cellIndex function exsisted!

Rich
Jul 23 '05 #7

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

Similar topics

5
by: flupke | last post by:
Hi, i'm having trouble with deleting elements from a list in a for loop ============== test program ============== el = print "**** Start ****" print "List = %s " % el index = 0 for line...
3
by: Stephen | last post by:
I've got a datagrid with a remove button and I would like to add some code in the code behind page so as whenthe button is clicked the corresponding row in the datagrid is removed. The Datagrid is...
10
by: AdamG | last post by:
I am trying hard for days now to add and delete rows to a table. I could really use some help... Each row contains two buttons (images) - 'add row' and 'delete row'. When the user clicks add...
13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
5
by: Ariel Gimenez | last post by:
Morning! After several hours breaking my mind, finally my code works, but i think is trash-code, can someone tellme how is the correct way to access the value of my cells within a datagrid?... in...
1
by: jez123456 | last post by:
Hi, I have a windows form with a listbox control. My code all works correctly when deleting an item from the listbox except the last item. I get the following message when trying to delete the...
5
by: John Veldthuis | last post by:
My code works perfectly 100% when adding items to my ArrayList and updating the listbox. Works perfectly when deleting an item in the ArrayList when it is not the last entry but if it is the last...
0
by: rn5a | last post by:
This is the code of a DataGrid: <asp:DataGrid ID="dgCart" OnEditCommand="EditCart" OnCancelCommand="CancelUpdate" OnDeleteCommand="DeleteFromCart" OnItemCommand="ButtonClicked"...
3
by: Seb | last post by:
As of now I execute the following code when selecting a row in a gridview. However can I somehow refer to the cells by name rather then their index? eg. String Name = row.Cells.Text; protected...
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:
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...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.