![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
|
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. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() |
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! |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
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.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|