javascript - Updating the database on click of a table row -


i having table in data being populated through database.now want click on 1 of row alert message displays , readstatus of row become true in database database gets updated .

now problem write code updating database dont want move different page so.

like table :

<input type=hidden name="notifyidd" id="notifyidd" value="<%=messageid%>"/>  <tr bgcolor="#5d1b90" color="#ffffff" onmouseover="changecolor(this, true,false);" onmouseout="changecolor(this, false,false);" onclick="donav('shownotification.jsp?mid=<%=messageid%>');">  <td><input type="checkbox" name="" onclick="doremove(event);"  width="20" class="select_all_mail" value=<%=messageid%>></td> <td callspan="3" width="1000px"><%=messagesubject%>  @   <%=sendingtime%></td>  </tr> 

and in onclick method of each row had called alert.but how update database ?

function donav(theurl)  {      var tt = document.myinbox.notifyidd.value;     alert(tt);   //document.location.href = theurl;   } 

as if uncomment line move next page.but want on same page only.please help

edit :

i wrote ajax code it.but gives error.please

$(document).ready(function() {     $('#myrow').click(function ()     {         $.ajax({             type: "post",             url: "shownotification.jsp", //this servlet             data: {                 notifyidd: $('#notifyidd').val()              },             success: function(msg){                           if(msg == "success")                     alert('data updated.');             }         });     });  }); 

here assign myrow id table row.also removed donav function now

my error image clicked :

http://postimg.org/image/vix1vzvq5/

though error resolved ajax call not functioning.for test make shownotification.jsp :

<body>     <% string notifyid = request.getparameter("notifyidd");%>     success </body> 

the error message says server-side code failing when looking attribute "groupid". post sending has notifyidd instead. server code has no way of knowing if should map groupid or not.

try this. if doesn't work, update error.

$(document).ready(function() {     $('#myrow').click(function ()     {         $.ajax({             type: "post",             url: "shownotification.jsp", //this servlet             data: {                 groupid: $('#notifyidd').val()              },             success: function(msg){                           if(msg == "success")                     alert('data updated.');             }         });     });  }); 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -