Change "value" of a <input> while clicking on query result, while more than one record
<p>I have a script that would change the value of a input field:
</p>

<pre class="lang-php prettyprint-override"><code>    &lt;script language="javascript"&gt;
    function klientid() {
    var getid = document.getElementById("getidfromsearch");//results
    var klid = document.getElementById("idklienta"); //input field
    if(getid != "0") {
    klid.value = getid.textContent;
    }
    &lt;/script&gt;
</code></pre>

<p>a search engine and this is how results are printed:</p>

<pre class="lang-php prettyprint-override"><code>    &lt;?php
    while($rowmilion = mysqli_fetch_array($resultmilion)) {
    ?&gt;
    &lt;a href="javascript:klientid()"&gt;
    &lt;table&gt;
    &lt;tr&gt;
    &lt;td style="font-weight:bold; width: 160px; text-align:right;"&gt;ID:&lt;/td&gt;
    &lt;td style="width:200px;" id="getidfromsearch"&gt;&lt;?php echo $rowmilion['id']; ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    &lt;/a&gt;
    &lt;?php } ?&gt;
</code></pre>

<p>Now, when as the result there is only one record and I click on the link, it does change the value of a input field fine.</p>

<p>When result consists of more than one record, whichever link I would click, it will always get the value from the first record for example:</p>

<pre class="lang-php prettyprint-override"><code>ID: 100
ID: 200
ID: 300
</code></pre>

<p>So when I click on the third position, it will still change the value of a input field to 100 instead of 300.</p>

<p>I quess, this is because all records get the same "ID"... But still, I can't make it work.</p>
