Here is a way to capture text that is selected within a textarea box. As with this article, I have only included what is necessary for the script to function on a recent browser like IE or Mozilla/Firefox. For an example of how to do this outside a textarea box with even more stringent browser requirements, see this article.
Here is the version for a textarea box: