Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding tags to textarea

Status
Not open for further replies.

s4dadmin

Programmer
Joined
Apr 27, 2003
Messages
107
Location
US
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 += &quot;<&quot; + format + &quot;></&quot; + format + &quot;>&quot;;
document.editor.tmessage.focus();
}


function writeDefault() {
document.writeln('<table align=&quot;center&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>');
document.writeln(' <tr>');
document.writeln(' <td>');
document.writeln('<a href=&quot;JavaScript:FormatText(B)&quot;><img class=&quot;cbtn&quot; src=&quot;images/Bold.gif&quot; hspace=&quot;1&quot; vspace=&quot;1&quot; align=&quot;absmiddle&quot; alt=&quot;Bold&quot; title=&quot;Bold&quot; onmouseover=&quot;button_over(this);&quot; onmouseout=&quot;button_out(this);&quot; onmousedown=&quot;button_down(this);&quot; onmouseup=&quot;button_up(this);&quot;></a>');
document.writeln(' </td>');
document.writeln(' </tr>');
document.writeln('</table>');
document.writeln('<table border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>');
document.writeln(' <tr>');
document.writeln(' <td>');
document.writeln('<textarea align=&quot;center&quot; name=&quot;' + fieldName + '&quot; id=&quot;' + fieldName + '&quot; style=&quot;width: ' + rteWidth + 'px; height: ' + rteHeight + 'px;&quot;></textarea>');
document.writeln(' </td>');
document.writeln(' </tr>');
document.writeln('</table>');
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top