I have been having a lot of trouble trying to get value into javascript and pass it to alert. Here is the code that I use to pass the value....
<img onclick="handpost()" id="colorface" name="red" src="http://www.asl-ela.org/image/redface.png" alt="Red face" /></a>
Then I use function to get the data from img tag....
<script type="text/javascript">
function handpost() {
var color = document.getElementById('colorface').name;
alert(color);
}
</script>
I keep getting alert box saying undefined. What does that mean?!?!?!

nameis not an<img>propertynameis a property of img element. You should usegetAttributeto get its value, try thisdocument.getElementById('colorface').getAttribute('name')nameis not a standard property onimgattributes, you shouldn't use it. Instead, it is better to usedata-nameas the wholedata-*realm as been reserved for custom values. developer.mozilla.org/en-US/docs/Web/Guide/HTML/… .. these values can also be accessed via jQuery'sdatamethod orgetAttribute('data-name')