php - Inserting variables within a javascript function parameter -
i looked everywhere , couldn't find specific answer question. tried suggestions no avail.
using ajax, javascript, php, , mysql. i'm creating script when called fetches user list. on user list include link manage information user. here stuck.
the link manage supposed linked manageplayer("userid") (ex: manageplayer(1)). javascript function, not yet created, use userid , pass on php generate mysql db info related user id.
the trouble is, can't figure out life of me how input manageplayer function parameter of variable userid link.
here code:
var userid = response.data[index].user_id; htmlstring += "<tr class='rowlight' height='30'> <td>" + response.data[index].user_name + "</td><td>" + response.data[index].first_name + "</td><td>" + response.data[index].last_name + "</td><td>" + response.data[index].email_address + "</td><td>" **+ "<a href='javascript:' onclick='manageplayer(\'' + userid'\');'>manage player</a>" + "</td></tr>";
the line ** direct problem is.
i appreciate of help! thanks!
try
+ '<a href="#" onclick="return manageplayer(\'' + userid +'\');">manage player</a>'
because need quote userid in single quotes ending with
<a href="#" onclick="return manageplayer('john')">manage player</a>
and @ end of manage player add
return false;
if eclipse not it, swap quotes
+ "<a href='#' onclick='return manageplayer(\""+ userid +"\");'>manage player</a>"
Comments
Post a Comment