Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have scenario where User can add a comments as many he wants and that comments get displayed under div element ... so now i want to provide delete functionality as well . if a user adds three comments and if he wants to delete particular one .How to provide this functionality
Posted
Updated 9-Jul-13 21:48pm
v4
Comments
Siddhesh Patankar 10-Jul-13 3:12am    
Please tell us what have you tried...
Torakami 10-Jul-13 3:37am    
function deleteParentElement(n){
n.parentNode.parentNode.removeChild(n.parentNode);
}


<input type="button" önclick="deleteParentElement(this)" value="Remove this DIV" />

I tried this .. its working fine .. but I dont why but I am getting scrollbar to scroll divs added by user
Torakami 10-Jul-13 3:44am    
And there is one more problem is that .. this function is deleting the div element .. but when user enter new comment .. the value again coming from database and old comment it gets displayed
Siddhesh Patankar 10-Jul-13 4:43am    
because you have only deleted the element and not the comment... You will have to delete the comment also from database or if you want to keep history of the comment add a bit field to the database as isActive whose value will become false when deleted. And populate the comments using isActive=true in the where clause of you SQL
Torakami 10-Jul-13 4:46am    
But How can i Map to database from div.Can you suggest me code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900