I have some buttons on a form which when depressed insert various HTML tags. I want to be able to highlight a certain chunk of text and insert the opening and closing tags either side of the highlighted text.

Does anyone have any idea how to do this ?

I'm stuck.
Thanks in Advance