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
Deleting a row in html table
Moderator: General Moderators
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.
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 doanjanesh 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.
Code: Select all
<script type="text/javascript">
function someFunction(rid) {
alert("you clicked on row: " +rid);
}
</script>
<td onclick="someFunction(rowID);">sup</td>