I am fetching record from database and printing it on table.
See the Image:
For Device-permission column I want to use Button which will show Disapproved (means device is approved )if value is "true" and OnClick on the button i want to call a function which will update the value "false " against the IMEI in to database (means now the device become disappoved to use ).. In the same way if the value is false I want to show a button which will display Approve means on click of it I want to call a function to update the value true at the place of false against that IMEI in database . The code is:
<script type="text/javascript">
/**
* This code declares your class and saves an object "blogentry" to the table on StackMob.
* StackMob will create the table for you automatically based on your JSON.
*/
$(document).ready(function() {
result();
function result() {
var device = StackMob.Model.extend({ schemaName: 'device' });
var mydevice = new device({ });
var q = new StackMob.Collection.Query();
q.equals('device_org', 1);
q.setRange(0,9).orderDesc('lastmoddate');
mydevice.query(q, {
success: function(modal) {
//After StackMob returns "Bill Watterson", print out the result
var array = modal.toJSON();
// console.debug(array);
//$('#data').html(array[0].user_name);
var val = array[0].lastmoddate;
$('#last_mod_date').attr('value', val);
var key;
var count = 0;
for(key in array) {
if(array.hasOwnProperty(key)) {
count ++;
}
}
//alert(count);
for(var i=0; i<=count; i++)
{
// if(array[i].org_img == localStorage.getItem("stackmob.oauth2.user"))
//alert(array[i].org_img);
//$('#last_mod_date').html(array[0].lastmoddate);
//alert(val);
$("#ui").append("<tr><td>"+array[i].device_IMEI+"</td><td>"+array[i].device_model+"</td><td>"+array[i].device_permission+"</td><td>"+array[i].device_nickname+"</td><td>"+ new Date(array[i].lastmoddate)+"</td><tr>");
//end if condition
} // end for loop
} //end success
}); // end imagesearch schema query
} // end result function
setInterval(check_newentry,1000);
function check_newentry() {
var device = StackMob.Model.extend({ schemaName: 'device' });
var mydevice = new device({ });
var q = new StackMob.Collection.Query();
q.orderDesc('lastmoddate');
mydevice.query(q, {
success: function(modal) {
//After StackMob returns "Bill Watterson", print out the result
var array = modal.toJSON();
// console.debug(array);
//$('#data').html(array[0].user_name);
// alert(lastmod_date_old +"..."+ lastmod_date);
if(lastmod_date_old < lastmod_date)
{
var val = array[0].lastmoddate;
$('#last_mod_date').attr('value', val);
var key;
var count = 0;
var counter=0;
for(key in array) {
if(array.hasOwnProperty(key)) {
count ++;
}
}
//alert(count);
for(var i=0; i<=count; i++)
{
if(counter<50)
{
$("#ui").append("<tr><td>"+array[i].device_IMEI+"</td><td>"+array[i].device_model+"</td><td>"+array[i].device_permission+"</td><td></td>"+array[i].device_nickname+"<td>"+new Date(array[i].lastmoddate)+"</td><tr>");
//------------------------------------------- end device schema code
counter++;
}
else
exit();
}
}
}
});
} // end check_newentry
});
</script>
So my question is: 1.How can i put the button with above described state. 2.How can i call a function when the "approved/disapproved button" is clicked and how can i access only that row value where Button got clicked..Thanks in advance !!!