How to pass a value of javascript variable on button click to jquery function?
<p>I have generated a number randomly to be concatenated with a string like below:</p>

<pre><code>var pid = Math.floor((Math.random() * 10000) + 1);
var str = "PERSONS";
var id = str.concat(pid);
</code></pre>

<p>I have a div section in the HTML with a button like this:</p>

<pre><code>&lt;div&gt;
    &lt;h4&gt;name&lt;/h4&gt;
    &lt;button OnClick='display(id);'&gt;Delete&lt;/button&gt;
&lt;/div&gt;
</code></pre>

<p>JavaScript:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    function display(id) {
        var a = id;
        alert(a); 
    }
&lt;/script&gt;
</code></pre>

<p>When I click the button inside the div section, I want to pass the value of ID which is generated randomly for this particular name, and delete the particular name from the database using AJAX. </p>

<p>How do I pass the corresponding ID value when the button is clicked? The ID value is generated randomly in JavaScript and not in PHP.</p>