Page 1 of 1
Deleting a row in html table
Posted: Sun Aug 07, 2005 5:43 pm
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
Posted: Sun Aug 07, 2005 6:11 pm
by feyd
they clicked the row.. your code should tell you...
Posted: Sun Aug 07, 2005 9:20 pm
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
Posted: Mon Aug 08, 2005 12:48 am
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.
Posted: Mon Aug 08, 2005 5:16 pm
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>