Passing a variable using an onclick event to a function for a dynamically created button
<p>Please find the code below. When I'm trying to pass the variable tmp_lnk from the onclick event to the function it throws up an error that tmp_lnk is not defined. How do I pass the variable to the function?</p>

<pre><code>if(fig_name[1]==img_name)
{
var tmp_lnk = "Supplementary Notes for Images/"+"6H-"+img_name/img_name+".pdf"
$("#notes1").append('&lt;div&gt;&lt;a onclick="On_Click(tmp_lnk)" id="closebutton"&gt;NOTES&lt;/a&gt;&lt;/div&gt;')
break;
}}

function On_Click(tmp_link)
{
    window.open("tmp_lnk");
}
</code></pre>

<p>}</p>
