<script> function func(obj) {document.getElementById("inputID").value=obj.src;} </script> <img src="..." onclick="func(this)">