I am working on a textarea where text editing icons are just above the textarea. I want to be able to click on an icon, for example B for Bold and have the tags <b></b> appear in the textarea with the cursor right behind it or in the middle of the tags. I already have the rich text editing down for IE5.5+. I want to have this established for users who do not have IE or Mozilla.
Here is the code I have so far
function formatText(format) {
document.editor.tmessage.value += "<" + format + "></" + format + ">";
document.editor.tmessage.focus();
}
function writeDefault() {
document.writeln('<table align="center" border="0" cellpadding="0" cellspacing="0">');
document.writeln(' <tr>');
document.writeln(' <td>');
document.writeln('<a href="JavaScript:FormatText(B)"><img class="cbtn" src="images/Bold.gif" hspace="1" vspace="1" align="absmiddle" alt="Bold" title="Bold" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);"></a>');
document.writeln(' </td>');
document.writeln(' </tr>');
document.writeln('</table>');
document.writeln('<table border="0" align="center" cellpadding="0" cellspacing="0">');
document.writeln(' <tr>');
document.writeln(' <td>');
document.writeln('<textarea align="center" name="' + fieldName + '" id="' + fieldName + '" style="width: ' + rteWidth + 'px; height: ' + rteHeight + 'px;"></textarea>');
document.writeln(' </td>');
document.writeln(' </tr>');
document.writeln('</table>');
}
Here is the code I have so far
function formatText(format) {
document.editor.tmessage.value += "<" + format + "></" + format + ">";
document.editor.tmessage.focus();
}
function writeDefault() {
document.writeln('<table align="center" border="0" cellpadding="0" cellspacing="0">');
document.writeln(' <tr>');
document.writeln(' <td>');
document.writeln('<a href="JavaScript:FormatText(B)"><img class="cbtn" src="images/Bold.gif" hspace="1" vspace="1" align="absmiddle" alt="Bold" title="Bold" onmouseover="button_over(this);" onmouseout="button_out(this);" onmousedown="button_down(this);" onmouseup="button_up(this);"></a>');
document.writeln(' </td>');
document.writeln(' </tr>');
document.writeln('</table>');
document.writeln('<table border="0" align="center" cellpadding="0" cellspacing="0">');
document.writeln(' <tr>');
document.writeln(' <td>');
document.writeln('<textarea align="center" name="' + fieldName + '" id="' + fieldName + '" style="width: ' + rteWidth + 'px; height: ' + rteHeight + 'px;"></textarea>');
document.writeln(' </td>');
document.writeln(' </tr>');
document.writeln('</table>');
}