473,624 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.getEle mentById('r2c2' ).colSpan="4"
cellRows = document.getEle mentById('table Chart').rows(1) ;
cellRows.delete Cell(2);
cellRows.delete Cell(2);
cellRows.delete Cell(2);

document.getEle mentById('r2c7' ).colSpan="4"
cellRows = document.getEle mentById('table Chart').rows(1) ;
cellRows.delete Cell(4);
cellRows.delete Cell(4);
cellRows.delete Cell(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.getEle mentById('r2c8' ).deleteCell()

but that gave me a javascript error..

Thanks,

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

document.getEle mentById('r2c8' ).parentElement .deleteCell();

Tim

"Rich Morey" <rw*****@27east .com> wrote in message
news:f6******** *************** ***@posting.goo gle.com...
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.getEle mentById('r2c2' ).colSpan="4"
cellRows = document.getEle mentById('table Chart').rows(1) ;
cellRows.delete Cell(2);
cellRows.delete Cell(2);
cellRows.delete Cell(2);

document.getEle mentById('r2c7' ).colSpan="4"
cellRows = document.getEle mentById('table Chart').rows(1) ;
cellRows.delete Cell(4);
cellRows.delete Cell(4);
cellRows.delete Cell(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.getEle mentById('r2c8' ).deleteCell()

but that gave me a javascript error..

Thanks,

Rich

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

document.getEle mentById('r2c8' ).parentElement .deleteCell();

Tim


No, but I will..

Thanks for the idea..

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

document.getEle mentById('r2c8' ).parentElement .deleteCell();

Tim

That worked!!! Thanks sooo much!!

:-)

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

document.getEle mentById('r2c8' ).parentElement .deleteCell();


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.getEle mentById('r2c8' );
cell.parentElem ent.deleteCell( cell.cellIndex) ;
---

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #6
>
Then use:
---
var cell = document.getEle mentById('r2c8' );
cell.parentElem ent.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
2731
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 in el:
3
3045
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 populated by the items in an arraylist shown in the code below. When the button is clicked I would also like the code to remove the items from the Arraylist. I've very little experience working with datagrids and arraylists so im finding this...
10
22200
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 row within a specific cell/row, the index of that row should be passed to a function that creates a new row using that index (the new row should be added directly below the row where the user clicked. The new row should contain all of the cells and...
13
9504
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 Dir(strLDB) <> "" Then Kill (strLDB) where strLDB is the path to the ldb file. The client advises that the ldb doesn't lurk after the program closes. Any ideas?
5
2371
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 some cases i can access the values with e.Item.Cells.Text, but in other cases i have to do weird thinks like the following: TextBox pp; //I know...disgusting!!! pp= (TextBox) e.Item.Cells.Controls ; int id = Convert.ToInt32(pp.Text );
1
7884
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 last item:- Specified argument was out of the range of valid values. Parameter name: '64' is not a valid value for 'Value'. The 64 reduces depending on how many listbox items are displayed.
5
2427
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 entry and you select another index it goes boom!!!. Funny thing is the SelectedIndex Changed routine fires off perfectly and then crash after the return from this code. Now looking around the news groups it appears to be a bug in the .net...
0
1488
by: rn5a | last post by:
This is the code of a DataGrid: <asp:DataGrid ID="dgCart" OnEditCommand="EditCart" OnCancelCommand="CancelUpdate" OnDeleteCommand="DeleteFromCart" OnItemCommand="ButtonClicked" OnPreRender="ChangeWidth" OnUpdateCommand="UpdateCart" AutoGenerateColumns="false" runat="server"> <Columns>
3
1013
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 void ExercisesGridView_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = ((GridView)sender).SelectedRow; String Name = row.Cells.Text;
0
8249
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8685
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
8633
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...
1
8348
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8493
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
7176
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
6112
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
4084
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
1797
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.