iam trying to use the code at below

Code:
function link(word) { 
var name = prompt("Link:", "http://"); 
var aTag =  '[' + tag + '=/'; var btag = '/]';
var createlink = aTag + name + btag;
} 

<a href="#" onclick="link('a');"><img alt="Link" src="createlink.gif" border="0"></a>
for adding link to my rich-text editor.

i can create pop-up box for the "link section"... but.... could some help me to add the writtens on pop-up, to the text-area?(adding "createlink" to text-area)

the writtens for link, must be added to the text area like this:

[link: /www.site.com/][/link]