Hi Im trying to pass multiple values with the HTML onclick function. Im using Javascript to create the Table
var user = element.UserName;
var valuationId = element.ValuationId;
$('#ValuationAssignedTable').append('<tr> <td><a href=# onclick="return ReAssign(\'' + valuationId + ',' + user + '\')">Re-Assign</a> </td> </tr>');
But in my Javascript function the userName is undefined and the valuationId is a string with the valuationId and the UserName combined
function ReAssign(valautionId, userName) {
valautionId;
userName;
}
If
valuationIdanduserare JavaScript variables, and the source code is plain static HTML, not generated by any means, you should try:If they are generated from PHP, and they contain string values, use the escaped quoting around each variables like this:
The logic is similar to the updated code in the question, which generates code using JavaScript (maybe using jQuery?): don’t forget to apply the escaped quotes to each variable:
The moral of the story is
Will get evaluated as:
Whereas you would need: