0

How can I pass argument in this code

$table += "<td>" + "<a href='#' onclick='myFunction(HERE_I_need_to_pass_an_argument);'>" + items[i].senderID +"</a>" +"------"+ items[i].startTime +"</td>";

function myFunction (myVariable) {
 // my other logic goes here
}

can you help me writing an alert on that like this:

alertValue = 10;
$table += "<td>" + "<a href='#' onclick='alert(alertValue );'>" + items[i].senderID +"</a>" +"------"+ items[i].startTime +"</td>";

function myFunction (myVariable) {
 // my other logic goes here
}

1 Answer 1

2
$table += "<td>" + "<a href='#' onclick='alert("+alertValue+");'>" + items[i].senderID +"</a>" +"------"+ items[i].startTime +"</td>";
Sign up to request clarification or add additional context in comments.

2 Comments

thank you so much, always stuck in quotes and double quotes ... aaagghhh ... anyway, that worked a big Thank You
I will accept your answer later, SOF did not allow me to accept your answer now, says after 8 min :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.