I know this is really basic javascript but for some reason, I can't seem to get my link's onclick function to work when passing a parameter.
I have tried escaping the quotes, adding different types of quotes and adding the raw variable as a string.
I have it working with the below but it says that "XYZ is undefined"
function renderLink(value, meta, record)
{
var type = record.data['name']; //value is XYZ
return '<a href="javascript:void(0);" onclick="getReport('+type+'); return false;"></a>';
}
function getReport(type){
alert(type);
}
return '<a href="javascript:void(0);" onclick="getReport('+type+'); return false;"></a>';
You need to escape the string:
return '<a href="javascript:void(0);" onclick="getReport(\''+type+'\'); return false;"></a>';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With