Get "ActivityID" from a PHP file and put it in a JS script.
<p>I'm making a travelguide. I'm displaying data(activity) from a database(mysql). Each activity has his own button. When you push this button you add that specific activity to your travelguide. This all works, but i must refresh the page to display the activities that are added to the guide. Now i have made a working javascript script, but it's not dynamic. </p>

<pre><code>function MakeRequest()
{
    var test = 1;
    var xmlHttp = getXMLHttp();

    xmlHttp.onreadystatechange = function()
    {
        if(xmlHttp.readyState == 4)
        {
            HandleResponse(xmlHttp.responseText);
        }
    }
    xmlHttp.open("GET", "get_test.php?q="+test, true); 

    xmlHttp.send(null);
}
</code></pre>

<p>You see de variable: "var test = 1;" 
The number 1 stands for the ActivityID 1. So now  if you push the button it shows the activity with the ActivityID = 1. If i change the number to 2, is shows the activity with the ActivityID = 2.</p>

<p>I want to change the variable: "var test = 1;" The number must automaticly be inserted, it must be the same number as the ActivityID of the activity where is push the button.</p>

<pre><code>&lt;?php
$sql = "SELECT * FROM activity";
$stm = $db-&gt;prepare($sql);
$result = $stm-&gt;execute(array());

while($row = $stm-&gt;fetch(PDO::FETCH_ASSOC))
{
    echo '&lt;div id="activity'.$row['ActivityID'].'"&gt;';
    echo '&lt;img src="data:image/jpeg;base64,' . base64_encode( $row['ActivityIMG'] ) . '" &gt;', '&lt;br&gt;';
    //echo $row['Activityname'], '&lt;br&gt;';
    //echo $row['Activitydescription'];
    echo '&lt;input type="button" class="addActivity" onclick="MakeRequest();" value="Activiteit toevoegen" data-activity="' . $row['ActivityID'] . '"&gt;';
    echo '&lt;/div&gt;';
}
?&gt;
</code></pre>

<p>This is the php file:"get_activity". This is the code that displays the data en display the button. This button gets automaticly the ActivityID from the specific activity. This way i only need one script for all the activities. I want to do the same with the javascript, but i don't know how?  </p>
