title: how to get image id on image click
body: <p>I am displaying images in a table and image id in same cell in  a text box.  how can i get value of each text box on text box click</p>
  
  <pre><code>   echo
          "&lt;td style='border:1px solid #F3F5F6;'; align='middle' width='20%'&gt; 
  
        &lt;figure&gt;
           $imageshow
           &lt;input type='text' size='4' id='imageid' name='imageid'  value='$PHPimageid'  onclick ='displayID();' /&gt; 
  
       &lt;/figure&gt;
  
        &lt;/td&gt;";
  
  
      function displayID()
      {
          alert(  document.getElementById("imageid").value  );
  
      }
  </code></pre>
  
  <p>imageshow: holds the image string to display image 
  PHPimageid: holds image id e.g 2001</p>
  
  <p>this is a sample code. Echo statement which displays image and image id is in while loop.</p>
  
  <p>All text boxes has right id value but Every time I click on textbox it displaces last loaded ID value  . e.g if there are 10 images from id 1 to 10 . no matter which text box i click , it shows id 10 
  how can i get individual id. 
  Hope this makes sense. if you need further information, d let me know. 
  thanks </p>
  
  <p>here is picture to give you an idea.</p>
  
  <p><img src="https://i.stack.imgur.com/QJBO7.jpg" alt="Picture of images"></p>