Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 22nd, 2005, 7:57 AM   #1
kirkl_uk
Programmer
 
kirkl_uk's Avatar
 
Join Date: Apr 2005
Location: England
Posts: 86
Rep Power: 4 kirkl_uk is on a distinguished road
Send a message via MSN to kirkl_uk
Tables & Checkboxes

I have a table, with many rows (obviously) and in each row I have a checkbox. When I click on a checkbox in any row, I want to dynamically add a row underneath the one in which the checkbox resides. Once the same checkbox is clicked again, I want to be able to delete the dynamically added row. I have given every row in the table a unique ID so that I can use getElementById(), but as rows are added and deleted, the row that comes back from this method is not in the same position as it was before, and therefore the ID I have assigned is no longer correct. Is it possible that, when clicked, I can get a reference to the row object that a checkbox belongs to?

var chkBox = event.srcElement;

So, using chkBox, can I get a reference to the container, which is a tr?

kirkl_uk

Last edited by kirkl_uk; Apr 22nd, 2005 at 8:13 AM.
kirkl_uk is offline   Reply With Quote
Old Apr 22nd, 2005, 11:19 AM   #2
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
you could give the tr a id then reference it with the id.

<tr id="someid">

also, you'll probably end up having the reference the table row through the table it's self. so you should give your table a name or something.

Another idea i just had, if the page is dynamic, you could make all the checkboxes a array. i have use this method before with php not sure if it will work with javascript.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Apr 22nd, 2005, 12:22 PM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
You could try using the DOM to create new table rows on the fly. Unfortunately, I don't know much about it, other than the fact that it's possible.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:16 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC