Q:

pass img direct path src to input onClick

i have this snippet:
<script>
  function changeValue(o){
    document.getElementsByName('NAME')[0].value=o;
  }
</script>

<span onclick="changeValue(this.innerHTML)" style="cursor: pointer;">One</span>
<span onclick="changeValue(this.innerHTML)" style="cursor: pointer;">Two</span>
<img src='image.gif' onclick="changeValue(this.src)" />

<input type="text" name="NAME" value="SOMETHING">

im trying to make it so when the img is clicked it passes the src that is in between the " " and not the actual url
right now clicking the image results in
http:/site.com/image.gif

being placed in the input
but i need it to be just
image.gif

in the input
how can i accomplish this?

A:

src property of HTMLImageElement object returns the full/computed source of the image. For getting the desired result you can use the getAttribute method which returns the specified value of an attribute.
this.getAttribute('src')

