SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    Non-Member
    Join Date
    Jul 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple Rich Text

    Well, I recently took it up on myself to redo all of the coding in my administator area and finished. However, when it came to updating a few templates for the site, I was dismayed, because the rest of the area looked so awesome and textarea was so plain. What had in mind was what if instead of:
    <if condition="$value == 1">Show text</if>
    I could have:
    <if condition="$value == 1">Show text</if>
    This is my failed code:
    HTML Code:
    function style_textarea(elid) {
    	target = document.getElementById(elid);
    	s = new String(target.innerHTML);
    	s = s.replace(/&lt;/g,"<span style='color:red;font-weight:bold;'>&lt;</span>",false); //<
    	s = s.replace(/&gt;/g,"<span style='color:red;font-weight:bold;'>&gt;</span>",false); //>
    	target.innerHTML = s;
    }
    Just a point in the right direction would be appreciated. Which functions would I go about using and how to apply them?

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    String.replace() doesn't have a third argument. Try removing them.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    Non-Member
    Join Date
    Jul 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, my code works. I say it failed because in the textarea tag you see "<span style='color:red;font-weight:bold;'><</span>" instead of "<" highlighted red.

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The third argument is being ignored then.

    A normal textarea can only contain text. You want a textarea replacement script. Check out this one: EditArea - the code editor in a textarea
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


Bookmarks

Posting Permissions

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