$("#radio5").click(function()
{
document.getElementById("ti").style.display="table";
$.ajax
({
type:"GET",
url:"inst.php",
dataType:"xml",
success: xmlInstructor
});
});
function xmlInstructor(xml)
{
$(xml).find('Instructor').each(function()
{
instructorName = $(this).find('InstructorName').text();
$("#ti").append("<tr><td>"+"<input type='button' id='instructorButton' onclick='i_click("+instructorName+")' value='ADD' />"+"</td><td>"+instructorName+"</td></tr>");
});
}
Code works fine until here. but I want to alert instructorName on i_click function which i am not able to get. If i pass integer it works but but not with string.
function i_click(instructorName)
{
alert(instructorName);
}
Not able to alert instructor.
Its because the string parameter is not surrounding with quotes
Replace this
With
This will fix your problem.