Reputation: 4920
how to call javascript function from anchor tag which is part of a javascript string?
var htmlVar = '<span> Name: ' + arNames[j] + '</span></br><span> Last: ' + arLast[j] + '</span><br/><a javascript:setProfile(\\"+ dob[j]+\\",\\"+state[j]+\\") >View</a>';
Upvotes: 0
Views: 5358
Reputation: 597
If I'm understanding your intention correctly (having a string that contains the HTML for a link that is a Javascript link), you could do it thus:
var htmlVar = '<span> Name: ' + arNames[j] + '</span></br><span> Last: ' + arLast[j] + '</span><br /><a onclick="javascript:setProfile(\\"' + dob[j] + '\\",\\"' + state[j] + '\\")">View</a>';
Upvotes: 3