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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Colors in a HTML textarea

Status
Not open for further replies.

Rodie

Programmer
Jun 27, 2004
132
FR
Hi all [2thumbsup]

Does someone know how I can have different colors in the same HTML textarea ?? with kind of frames ??

Thanks a lot, if you have ever tried it [tongue]

Rodie [bigglasses]
 
Indeed, I mean <textarea>
Forget frames, I'm just very beginner ... :)
 
Can't. One color per textarea. If you need multiple colors, look at one of the WYSIWYG html editors. I like FCKEditor.
 
Thanks, you are right.
Then I tried FCKEditor, especially the doc that gave me this piece of code :

Code:
<html>
  <head>
    <script type="text/javascript" src="/FCKeditor/fckeditor.js"></script>
    <script type="text/javascript">
      window.onload = function()
      {
        var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
        oFCKeditor.ReplaceTextarea() ;
      }
    </script>
  </head>
  <body>
    <textarea id="MyTextarea" name="MyTextarea">This is <b>the</b> initial value.</textarea>
  </body>
</html>

It does not work [sadeyes]
I see This is <b>the</b> initial value. instead of seeing the word the in bold format..

You know what does not work on the code ?
(I checked that I properly refer to the Javascript in the right folder).

Thanks !
 
The error that is displayed by my browser (IE) is:

Error: The TEXTAREA id "My Textarea" was not found

Thanks if someone has an idea. Because there is a "MyTextarea" !!
 
I downloaded another version of FCKeditor.
My TEXTAREA is recognized.
But now, the execution of the previous piece of code replace my textarea by the famous "The page cannot be found" page, this being include in a kind of textarea.

Any idea ?
Thanks a lot [smile2]
 
I am not affiliated with FCKEditor. If you have any questions with how it is working, I suggest you ask at the website itself. Alternatively, you could try a simpler widgEditor.
 
Thanks ! widgEditor works.
But actually, I don't really need an editor because I will insert colors with PHP.

For example : if (word == "Robert") then (word.color = red)

For that, I think the easier is to have a Textarea where I can do something like this :

Code:
<textarea name="mytext"></textarea>
...
<script>
mytext.value = PHPfunction("I am Robert");
</script>

with PHPfunction that changes the text in : I am <font color=#ff0000>Robert</font>

I hope you understand what I mean. Do I have to modify the WYSIWYG by myself ? Or it exists a "rich" textarea without editor on the Web ?

Thanks a lot [smile2]
 
It's OK.
I'm going to use an <iframe>
Thanks to you guys.
 
Why do/did you want a <textarea> if it's not going to be editable? If what you really want is an area of text on your page surrounded by an inset border, you can do that with a little simple CSS. Just put this is the <head> of your document (or a seperate stylesheet, without the <style> tags):
Code:
<style>
.inset {
   border: 2px solid #CCC;
   border-left-color: #999;
   border-top-color: #999;
}
</style>
Now mark off the bit you want to frame like this:
Code:
<div class="inset">
This looks like a textarea!
</div>

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Indeed, you are right. I cannot use a Textarea ... I'm too persistant ;)

Your code is interesting, but I also would like a scrollbar, that scrolldown automatically when you write in the "textbox". I did not find how to do that ...

Thanks for your help !
 
Oops .. I can do that:

Code:
<DIV class="inset" 
  style='width: 350px;
  height: 100px;
  overflow-y:scroll;
'>
for example.

But I would like to have only a vertical scrollbar. And when the text is long horizontally, it goes automatically to the line, like a textarea.

Anyone has an idea ?
Thanks a lot again.
 
First, overflow-y is a IE only property, so it is best avoided. As for the horizontal scroll, it should not appear normally -- that is if you put in the text that has spaces, text should wrap nicely and produce no horizontal scrollbar, but only vertical. Try overflow: auto; to achieve that (note, scrollbar will not be visible until content starts overflowing).
 
Ok interesting. Indeed, there is an horizontal scrollbar when overflow .. and I really would like to go to the line (fixed width I mean ..)

My other problem is: I just realized that I don't know how to write into a <DIV> like in a <TEXTAREA>.
If my DIV is called "MyDiv", I cannot do something like:
Code:
MyDiv.value += "text"
in a extern function ??

Thanks if you know
 
Oh thanks !!!
It works ;)
Thanks to all of you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top