Deleting a row in html table

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
brindha
Forum Newbie
Posts: 2
Joined: Sun Aug 07, 2005 5:23 pm

Deleting a row in html table

Post by brindha »

Hi,

I have created a table dynamically. for example when a user clicks on Add button, a row is added dynamically to the table.The question is after the creation of table,if the user selects a row and click delete,how would i know that which row he has selected for delete.


Thanks,
Lekshmi
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

they clicked the row.. your code should tell you...
brindha
Forum Newbie
Posts: 2
Joined: Sun Aug 07, 2005 5:23 pm

Post by brindha »

Please explain in detail...see the application is developed by some one and used by some ithers ie user.
So my question was whenever some one click on the dynamically generated table ,how would we able to find out the row that has been clicked
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

1. If you have a checkbox next to the row then clicking the checkbox and deleting is easy. Just check for value of the checkbox id.

2. If theres no checkbox and user is clicking on the row itself and you want to know if the row is 'selected' or not then simply switch background colours and check for the cell id's style.backgroundColor. And delete rows which have a particular background colour.
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

anjanesh wrote: 2. If theres no checkbox and user is clicking on the row itself and you want to know if the row is 'selected' or not then simply switch background colours and check for the cell id's style.backgroundColor. And delete rows which have a particular background colour.
No need to change the bg color...just do

Code: Select all

<script type="text/javascript">
function someFunction(rid) {
alert("you clicked on row: " +rid);
}
</script>
<td onclick="someFunction(rowID);">sup</td>
Post Reply