Trouble Populating Anchor Text in TextArea

I am creating a simple, small CMS module for a client. I created a little form and when they click Submit, it goes straight out into an include (.inc) file, which is connected to the web page to be displayed.

One of the buttons I want to insert an example URL so they don’t have to mess around with tags. I need it to exactly insert this into the textarea:

<a href=“http://www.example.com”> Link Text Here </a>

Since the data from the textarea gets passed into an html page, I need to be able to pass the anchor tags too. The trouble is, the string (highlighted below) wants to read it as an actual URL and not just spit it out as plain old text. I can make it populate plain old text - that works just fine. But instead it acts like I am trying to put actual html in there… Is there some special trick I am missing?

<form method=“post” action=“<?=$_SERVER[‘PHP_SELF’]?>”>

&lt;script type= "text/javascript"&gt;

// myField accepts an object reference, myValue accepts the text string to insert at the cursor

function insertatcursor(myField, myValue) {
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
else if (myField.selectionStart == 0 || myField.selectionStart == ‘0’) {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0,startPos) + myValue + myField.value.substring(endPos, myField.value.length);
}
else {
myField.value += myValue;
}
}
</script>

<table width=“50%” border=“0” align=“center” cellpadding=“1” cellspacing=“1” valign=“top”>
<tr>
<td width=“2%”></td>
<td align=“center” valign=“top”>
<textarea id=“mytext” name=“savecontent” cols=“50” rows=“10” style=“text-align: left; padding: 0px; overflow: auto; border: 3px groove; font-size: 12px”><?=$loadcontent?></textarea></td>
<td align=“left” valign=“top” width=“60%”>
<input name=“url” type=“button” value=“insert url” onclick=“insertatcursor(document.getElementById(‘mytext’), ‘<a href=“http://www.example.com”>Link Text</a>’); return false;”>
</td>
</tr>
<tr>
<td></td>
<td align=“center” valign=“top”><input type=“submit” name=“save_file” value=“SAVE”> </td>
<td align=“left” valign=“top”> </td>
</tr>
</table>

<br />
</form>

How do things go when you escape the intended text content?

I dont know what you’re asking exactly?

but I figured out the answer and I thought that I’d share;

<input name=“url” type=“button” value=“insert url” onclick=“insertatcursor(document.getElementById(‘mytext’), ‘\x3ca href=\x22http://www.example.com\x22 target=\x22_blank\x22>Link Text\x3c/a\x3e’); return false;”>

Awesome!!