I would like to change the value of a textarea when hovering over a link. I am not very proficient at javascript and do not quite understand the intricacies of ‘this.’ and ‘document.’ etc..
Currently I have a textarea ‘info’ that on page load is unpopulated and two links that should change its value. I can not seem to get it to work..
<textarea name="info"></textarea>
<a href="foo.com" onmouseover="document.info.value='foo.com is a great site'">Foo.com</a>
<a href="bar.com" onmouseover="document.info.value='bar.com is a terrible site'">Bar.com</a>
I’m sure there is a way to accomplish what I need to do but I can’t find it.
Thanks in advance.
Create a function, that accepts the string you want, and sets the textarea:
Assign an ID to the textarea, and call the function in the onmouseover, passing the string you want to set:
Example: http://jsfiddle.net/nmZb9/