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
echo
"<td style='border:1px solid #F3F5F6;'; align='middle' width='20%'>
<figure>
$imageshow
<input type='text' size='4' id='imageid' name='imageid' value='$PHPimageid' onclick ='displayID();' />
</figure>
</td>";
function displayID()
{
alert( document.getElementById("imageid").value );
}
imageshow: holds the image string to display image PHPimageid: holds image id e.g 2001
this is a sample code. Echo statement which displays image and image id is in while loop.
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
here is picture to give you an idea.