I want to implement a dialog box which will open as soon as i will click a table row.Basically want to edit the database through table rows. The table content is stored into the database and fetched from there. If I will edit the row then the database also should be updated automatically. When I will click on the row then dialog box will fetch some particular cell from row and i will modify it or delete the row and the result should be visible immediately in the table. I want to do it through jquery, ajax. After opening the dialog box ajax should call a servlet and modify the database. Please give the code also.
<fieldset id ="allTweets">
<table cellspacing="20" class ="tweetTable" >
<caption>Tweets</caption>
<%
while(rs.next()){
%>
<tr id="ForChangingTweet">
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
</tr>
<%
}
%>
</table>
</fieldset>
Here is my jquery
$('#ForChangingTweet').click(function ()
{
$("#dialog").dialog({
autoOpen: true,
modal: true,
width: 600,
height: 300,
resizable: false,
buttons: {
"Yeah!": function() {
$(this).dialog("close");
},
"Sure, Why Not": function() {
$(this).dialog("close");
}
}
});
$.ajax({
type: "post",
url: "ChangeTweets",
data: {
notifyidd: $(this).attr("id")
},
error : function(){
alert('Error');
},
success: function(msg){
alert('Success');
}
});
});
I have also added some js files
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/ui-darkness/jquery-ui.css" rel="stylesheet">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
last two in the each row is my target