SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image into a textarea

    Hey guys, I have a small functions that adds smiley's to a text area, at the moment it just adds the characters for the smileyi.e ": )" for a smiling face, then I do a string replace using php when I display them. However, I would like the smiley to appear in the text area im posting my message in, how can this be achieved as the text area will not except smiley's?

    Thanks in advance
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  2. #2
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's not possible, textareas can only have text in. The only way you could do something similar is with a WYSIWYG component - here's a comparison of the top ones.

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <form><textarea id=post rows=20 cols=30>
    funny :) sad :(
    </textarea></form>
    <script>
    setInterval(function() {
    	var q = document.forms[0][0], v = q.value;
    	if(v.match(/:[()]/))
    		q.value = v.
    			replace(/:\)/g, '\u263a').
    			replace(/:\(/g, '\u263b')
    }, 100)
    </script>

  4. #4
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
     
    <form><textarea id=post rows=20 cols=30 style="font-size:20px;">
    funny :) sad :(
    </textarea></form>
    <script type="text/javascript">
    window.onload=aa() 
    
    function aa() {
    var e = document.getElementById('post');
    e.value=e.value.replace(/:\)/g, '\u263a') ;
    e.value=e.value.replace(/:\(/g, '\u263b') ;
    
    setTimeout("aa()",500) ;
    }
    	
    </script>
    Last edited by muazzez; Jan 10, 2007 at 16:23.


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
  •