Using same script with different input over same html
<p>im trying to make a JavaScript to use the same code over different parts of an html code, the script read the title, runtime and plot from a specific url request and should place that information inside the correct div. How can i do this?</p>

<pre><code>&lt;div&gt;
  &lt;input id="img1" type="radio" name="img-descr"&gt;
     &lt;div id="tt0110912"&gt; &lt;!-- Pulp fiction --&gt;
         &lt;h1 id="Title"&gt;&lt;/h1&gt;
         &lt;p id="Runtime"&gt;&lt;/p&gt;
         &lt;p id="Plot"&gt;&lt;/p&gt;
     &lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
  &lt;input id="img2" type="radio" name="img-descr"&gt;
     &lt;div id="tt0796366"&gt; &lt;!-- Star Trek --&gt;
         &lt;h1 id="Title"&gt;&lt;/h1&gt;
         &lt;p id="Runtime"&gt;&lt;/p&gt;
         &lt;p id="Plot"&gt;&lt;/p&gt;
     &lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
  &lt;input id="img3" type="radio" name="img-descr"&gt;
     &lt;div id="tt0251413"&gt; &lt;!-- Star Wars --&gt;
         &lt;h1 id="Title"&gt;&lt;/h1&gt;
         &lt;p id="Runtime"&gt;&lt;/p&gt;
         &lt;p id="Plot"&gt;&lt;/p&gt;
     &lt;/div&gt;
&lt;/div&gt;

&lt;!-- Script para la api de OMDB --&gt;    

&lt;script&gt;            
var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (xhr.readyState == XMLHttpRequest.DONE) {
            var fullMovie = JSON.parse(xhr.responseText);
            var movie = { title: fullMovie.Title, runtime: fullMovie.Runtime, plot: fullMovie.Plot, };
            document.getElementById('Title').innerText = movie.title;
            document.getElementById('Runtime').innerText = movie.runtime;
            document.getElementById('Plot').innerText = movie.plot
        }
    }
    xhr.open('GET', 'variable?', true);
    xhr.send(null);
&lt;/script&gt;
</code></pre>

<p>The following url is called for each movie:</p>

<pre><code>http://www.omdbapi.com/?i=tt0110912&amp;plot=short&amp;r=json  (Pulp Fiction Movie)
http://www.omdbapi.com/?i=tt0796366&amp;plot=short&amp;r=json  (Star Trek Movie)
http://www.omdbapi.com/?i=tt0251413&amp;plot=short&amp;r=json  (Star Wars Movie)
</code></pre>

<p>How can i add an id to the div with the correct ?i=tt******* information so the script add the correct answer to the title, runtime and plot section?</p>

<p>Thinking on it the script should, read the div id, use that id to fetch the information:</p>

<pre><code>var search = document.getElementById('dividhere').value;
xhr.open('GET', 'http://www.omdbapi.com/?i=+search+&amp;plot=short&amp;r=json', true);
xhr.send();
}
</code></pre>

<p>The script should read the  and run the xhr.open with that id information, place the information fetched inside that div and run the script on the second div, and again on the third div. So if i add another div with a new id information the script will load for the new movie.</p>