Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2004
    Location
    Sweden
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Replace text in textarea

    <html>
    <head>
    <title>test</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

    <script>
    function replace(){
    document.form.txt.replace(/&lt;script&gt;/, "<font color='red'>&lt;script&gt;</font>");
    }
    </script>
    <body>
    <form name="form">
    <textarea name="txt" cols="20" rows="20" onKeyUp="javascript:replace();">test &lt;script&gt;</textarea>
    </form>
    </body>
    </html>


    ------------------------------------------

    You problably understand what I want to get out of this.

    I want that when you eg. write "<script>" in the textarea it turns red (only the word script)

    I'm not totally of the road with this code right? Please help...

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can not do that. The textarea text color is all the same color.

  • #3
    New Coder
    Join Date
    Feb 2004
    Location
    Sweden
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok
    but it should be possible if i use editable div's right?

    ex.

    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    <style type="text/css">
    DIV.editor {
    width: 60%;
    height: 100%;
    font-family: Courier New;
    font-size: 13px;
    padding: 10px;
    border: 1px solid #000000;
    }
    </style>

    <div id="editor" class="editor" contentEditable></div>


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    but I can't put it together, please help...
    Last edited by Matt_Helvey; 07-08-2004 at 08:35 AM.

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Matt_Helvey
    ok
    but it should be possible if i use editable div's right?
    yes, but you can't directly submit them to the server. you'll have to copy their contents, plus any extra formatting markup to a hidden textarea, before submission.

  • #5
    New Coder
    Join Date
    Feb 2004
    Location
    Sweden
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what?

    I only want it to be an editor with. No submissions or whatever you're talking about. Can someone givé a code example???

    Sorry but this is really beginning to get on my nerves


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •