Question

TextArea Editor

Asked by: B_Dorsey

I have a textarea box on my website, and allow HTML encoding in it, but I found no one uses the HTML cause they dont know basic html,

I would like to put a few buttons on the top that will allow html editing, for example if in the text are the user types "hello my name is Bill" I would like them to highlight the word Bill and then click the bold button above and it would bold the text and then when submitted would include the html in the submission.

Bill D

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2003-09-05 at 13:11:12ID20730488
Tags

textarea

Topic

JavaScript

Participating Experts
7
Points
500
Comments
16

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. How to make hilighted textarea word turn bold
    If I have a textarea <form> <textarea name=t>This is the text</textarea> </form> I want to select the word "the", click a button that says "Make Bold", and have the word "the" turn bold in the textarea. Not just put <...
  2. tagging textarea
    I have seen many threads arround the web about this, but none seem to answere it. Many forums (YaBB and PHPbb come to mind) have text area's where you enter your post, and buttons above to add UBBC tags. I have had a look at these forums but cant for the life of me find the j...
  3. textarea with jsp
    hi there, i have this data, as from the database. >> <B>xxx</B> <B>resume</B> <B>artemis</B> <B>apollo</B> <B>license</B> <B>key</B> <B>copyright</B> <B>war</B> <B>le...
  4. Insert bold tag in textarea bug
    Hi, Using some code from another post, I am able to added <b> and </b> tags to a selected area. The problem is that when nothing is selected the <b> and </b> tags get added to the page (in front of the link or button used to create it). Is there any ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: adilkhanPosted on 2003-09-05 at 13:16:39ID: 9298547

here View the Code for this Example.

http://marxidad.editthispage.com/TextEditorDemo

 

by: adilkhanPosted on 2003-09-05 at 13:18:18ID: 9298557

 

by: COBOLdinosaurPosted on 2003-09-05 at 13:20:13ID: 9298570

FROM:

http://msdn.microsoft.com/Downloads/samples/Internet/ie55/editregions/editregions.htm


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<TITLE>Editable Regions Sample</TITLE>

<LINK REL="stylesheet" HREF="/workshop/samples/author/dhtml/refs/samplessdkIE4.css" TYPE="text/css">

<STYLE>
body{
margin:0;
background:white;
font-family:verdana;
font-size:80%;
}
.bar{
background:#336699;
width:100%;
height:30px;
border-top:1px solid #99CCFF;
border-bottom:1px solid #000000;
}
.desbar{
background:#FFFFFF;
width:100%;
padding: 10px;
border-top:1px solid #CCCCCC;
border-bottom:1px solid #000000;
color:black;
font-size:8pt;
height:105;
}
.title{
font-size:15pt;
color:white;
padding-left:10px;
}
PRE { margin:0}

a:link
{
text-decoration:none;
color:white
}
a:visited
{
text-decoration:none;
color:white
}
a:active
{
text-decoration:none;
color:white
}
a:hover
{
text-decoration:none;
color:yellow
}
BUTTON {cursor:hand; background:#ffffff; border-color:#99ccff; font-weight:bold;}
</STYLE>


<SCRIPT>
function fnToggleEdits(oObj,oBtn) {
    currentState = oObj.isContentEditable;
    newState = !currentState;
    oObj.contentEditable = newState;
   
    newState==false ? oBtn.innerHTML='Editing On' :
        oBtn.innerHTML='Editing Off';
}
</SCRIPT>

</HEAD>

<BODY >
<!-- TOOLBAR_START --><!-- TOOLBAR_EXEMPT --><!-- TOOLBAR_END -->
<DIV CLASS="bar title">
Editable Regions Sample
</DIV>
<DIV CLASS="desbar">
<H4 style="font-size:10pt;">
This example demonstrates the features of Microsoft&#174; Internet Explorer that enable users to edit the content of an HTML element directly from the browser.
</H3>
<P> This HTML editor is a DIV element set to be content editable. Any valid HTML content (text, images, form controls, etc.) can be pasted and edited in this editor.</P>

<div align="center">
<DIV UNSELECTABLE ALIGN="center" STYLE="height:210; width:90%; background-color:#99CCFF; border:1px solid black">  
    <DIV CLASS="bar title">HTMLEditor (Content Editable DIV)</DIV>

<DIV style="padding:10px">
  <BUTTON UNSELECTABLE ID="oEditDiv" TITLE="Editing Off" onclick='fnToggleEdits(oDiv,oEditDiv);oDiv.focus();'>Editing Off</BUTTON>  
  <BUTTON UNSELECTABLE  TITLE="Bold" onclick='if (oDiv.isContentEditable==true) document.execCommand("Bold"); oDiv.focus();' >Bold</BUTTON>  
  <BUTTON UNSELECTABLE  TITLE="Italic" onclick='if (oDiv.isContentEditable==true) document.execCommand("Italic"); oDiv.focus();' ><I>Italic</I></BUTTON>  
  <BUTTON UNSELECTABLE  TITLE="Underline" onclick='if (oDiv.isContentEditable==true) document.execCommand("Underline"); oDiv.focus();'><U>Underline</U> </BUTTON>
 
</DIV>
  <DIV id=oDiv contenteditable ALIGN=left STYLE="height:100; width:95%;background-color:white; font-face:Arial; padding:3;    
   border:inset #99ccff; scrollbar-base-color:#99ccff; overflow=auto;"></DIV>
<BUTTON UNSELECTABLE TITLE="Append from HTMLEditor" onclick='oTextarea.value+=oDiv.innerHTML;oTextarea.focus();'>
      Append to TextEditor</BUTTON>
   
</DIV>
</div>
<BR/>

<P>This text editor is a TEXTAREA element and is content editable by default. Only text can be edited in this tool. However, you can draft HTML in TEXTEditor and press the Append to HTMLEditor button to see the result appended to HTMLEditor. The Append to TextEditor button reverses this process by appending the HTMLEditor's HTML as text to TEXTEditor.<BR/><BR/>
<br>

<div align="center">
<DIV UNSELECTABLE ALIGN="center" STYLE="height:210; width:90%; background-color:#99ccff; border:1px solid black">  
    <DIV CLASS="bar title">TEXTEditor (TEXTAREA)</DIV>
      
<DIV style="padding:10">
      
      <BUTTON UNSELECTABLE ID="oEditText" TITLE="Editing Off"
      onclick='fnToggleEdits(oTextarea,oEditText);oTextarea.focus();'>Editing Off</BUTTON>
</DIV>
   
  <TEXTAREA id=oTextarea ALIGN=left STYLE="height:100; width:95%;background-color:white; padding:3; border:inset #99ccff; scrollbar-base-color:#99ccff; overflow=auto;"></TEXTAREA>  
  <BR/>
      <BUTTON UNSELECTABLE TITLE="Append to HTMLEditor" onclick='oDiv.innerHTML+=oTextarea.value;oTextarea.focus();'>  
   Append to HTMLEditor</BUTTON>
</DIV>
</div>
<BR/><P>Both editors use the same function to activate or deactivate editing. The function uses the <b>isContentEditable</b> property to test whether editing is active. Accordingly, the <b>contentEditable</b> property is then reversed to reset editing.
</DIV>

<DIV CLASS="bar" STYLE=" padding:5px; padding-left:10">
<A href="http://www.microsoft.com/misc/info/cpyright.htm" target=_top>
&#169;2002 Microsoft Corporation . All rights reserved. Terms of use</A>.
</DIV>
<P><HR><font color="black" face="ms sans serif" size="1">&copy;<a href="http://msdn.microsoft.com/isapi/gomscom.asp?TARGET=/info/cpyright.htm" target="_top"> 2002 Microsoft Corporation .  All rights reserved.  Terms of use.</a></font>
</body>
</html>

Cd&

 

by: jaysolomonPosted on 2003-09-05 at 13:24:47ID: 9298608

 

by: jaysolomonPosted on 2003-09-05 at 13:25:06ID: 9298611

sorry did not reload the Q

 

by: B_DorseyPosted on 2003-09-05 at 13:33:04ID: 9298669

@COBOL
That is what I was looking for, the first example from adilkhan was kinda right but I didnt want to see the HTML code, jsut the result of HTML code

I am no good at JS, how would I go about making this one box (the tope one) and have it included with my already existent form, my textarea is called "J_CONTENT", could you put a sample little thing together with one or two options (Bold and Links) and Im sure I could figure it out after that.

Thanks Very Much, appreciate the fast responses from everyone :)

Bill D

 

by: COBOLdinosaurPosted on 2003-09-05 at 13:40:06ID: 9298704

Okay.  I have a couple of things to do here at work first, and then I see if I can give you a simple piece to plug in.

Cd&

 

by: B_DorseyPosted on 2003-09-05 at 13:43:57ID: 9298729

thx

Bill D

 

by: COBOLdinosaurPosted on 2003-09-05 at 15:38:12ID: 9299312

kay here is a simplified version with several edit functions.  Hyperlinks are automatically generated for any url that is typed in.

Note yu still have to have both boxes but the one that submits the HTML is now hidden.  You have to do it theis way because the information has to move back and forth between an editable div and a text area t preserve the formatting when it gets to the server.  

When the form gets submitted the content in the edit area is automatically sent to the text area as html and that is what get submitted.  if yu are brining the content back, then the sting goes into the hidden textarea and yu display it in the dive by doing the body tag this way:

<body onLoad="oDiv.innerHTML=oTextarea.value">

If they then re-edit it, the new versin will be moved to the text area when they submit.


Cd&



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Small Editor</title>
<style>
body{
margin:0;
background:white;
font-family:verdana;
font-size:80%;
}
a:link
{
color:blue
}
button {cursor:hand; background:#ffffff; border-color:#99ccff; font-weight:bold;}
</style>
</head>

<body>
<div align="center">
<div UNSELECTABLE align="center" style="height:210; width:90%;">  
    <div>HTMLEditor (Content Editable DIV)</div>

<div style="padding:10px">
  <button UNSELECTABLE  title="Bold" onclick='if (oDiv.isContentEditable==true) document.execCommand("Bold"); oDiv.focus();' >Bold</button>  
  <button UNSELECTABLE  title="Italic" onclick='if (oDiv.isContentEditable==true) document.execCommand("Italic"); oDiv.focus();' ><i>Italic</1></button>  
  <button UNSELECTABLE  title="Underline" onclick='if (oDiv.isContentEditable==true) document.execCommand("Underline"); oDiv.focus();'><u>Underline</u> </button>
</div>
  <div id=oDiv contenteditable align=left style="height:100; width:95%;background-color:white; font-face:Arial; padding:3;border:4px inset gold"></div>  
</div>
</div>
<form method="get" action="somescript.asp">  

<div UNSELECTABLE STYLE="display:none">  
  <textarea name="tarea" id=oTextarea align=left style="height:100; width:95%;background-color:white; padding:3; border:inset #99ccff; scrollbar-base-color:#99ccff; overflow=auto;"></textarea>  
</div>
<!--
   THE REST OF YOUR FORM ELEMENTS GO HERE
-->

<input type="submit" onclick='oTextarea.value+=oDiv.innerHTML'>
</form>
</body>
</html>

 

by: NushiPosted on 2003-09-06 at 04:01:20ID: 9300994

 

by: a_pravarakhyaPosted on 2003-09-06 at 06:29:50ID: 9301242

Very high quality HTML editor with source code:
http://www.fredck.com/FCKeditor/Demo/
(This HTML text editor brings to the web many of the powerful functionalities of known desktop editors like Word. It's really lightweight and doesn't require any kind of installation in the client computer.
As it is Open Source, you are allowed to use it for free wherever you want.)

Text Area Editor for HTML written in javascript, with source code:
http://www.codeproject.com/jscript/w3richtechedit.asp?target=yahoo%7Ceditor

 

by: IceMetalPunk2008Posted on 2003-09-06 at 14:44:04ID: 9302819

Hi-
  I know this has nothing to do with any of this, but I don't have enough points to ask a question. I would like to know if there is a way to find the position of the cursor in a textarea. Like, say the user clicks somewhere in a textarea. I would like to find where they clicked, or what character the cursur is at. Is this possible?
  -IceMetalPunk2008

 

by: COBOLdinosaurPosted on 2003-09-06 at 15:18:27ID: 9302992

No all you can get is the position relative to the top-left of the textarea in pixels.

Cd&

 

by: GaryC123Posted on 2003-09-06 at 15:43:21ID: 9303068

Cant see this in any comments (if there is a link to it sorry) so
http://www.interactivetools.com/products/htmlarea/

Excellent tool

 

by: B_DorseyPosted on 2003-09-06 at 16:46:48ID: 9303308

Thanks Cobol

I got what I needd with that

@Gary
I would like to upgrade to what you posted but am unable to make it work in XSL, have you got an example (or piece of script) that works in XSL, I will post seperate points I just wanted to keep in this question.

Bill D

 

by: COBOLdinosaurPosted on 2003-09-07 at 07:26:52ID: 9304788

Glad we could help.  Thanks for the A. :^)

Cd&

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...