How to access values of 'this'
Can't seem to work out how to pass values of
this around.
In the code below 'pData' is passed back from AJAX. In the generated table I click on a displayed 'id' class='disp'.
choice=$(this).text() gives the value of 'id'. How can I get the associated data for that record with that 'id'.
function showTable(pData) {
-
var table_str="";
var prev="";
var i=0;
var last="";
table_str = "<table id='peopleTbl' class='center' border='4' cellspacing='6' cellpadding='4' bgcolor='#fff99d' ><br/>";
table_str+="<thead><tr><th>Id</th><th>Name</th><th>Category</th><th>Phone</th><th>Cell</th><th>Notes</th></thead><tbody>";
$.each(pData, function() { // get people data
table_str+="<tr><td class='disp'>"+this.id+"</td><td>"+this.Last+", "+this.First+
"</td><td>"+this.Category+"</td><td>"+this.Phone+"</td><td>"+this.Cell+"</td>";
table_str+="<td colspan='2'><textarea id='txtout' disabled rows='3' cols='40'>"+
this.Notes + "</textarea></td></tr>";
}); // each
table_str+="</tbody></table>";
$("#rbox").empty();
$("#rbox").append(table_str + "<p></p>");
$('.disp').click(function () {
choice=$(this).text();
last=this.Last; // doesn' work
var flag=window.prompt("Revise or Delete","Revise");
if(flag=="Revise") {
window.location.href="pollyRevise.html?recId="+choice+"&last="+last;
}
}); // disp
} // showTable