liquidspaceman Posted February 18, 2010 Share Posted February 18, 2010 I'm using a script to insert a smiley "word" into a text field. I then use PHP to change the text word into a smiley. The only issue is that the code I'm using inserts the word on a new line, it does an automatic line break. Is there any way to alter this code so it drops the smiley exactly where the cursor lies, like THIS: Would appreciate it if you could help me out. <script type="text/javascript"> window.onload=function() { pic=document.getElementById('smilies').getElementsByTagName('img'); for(c=0;c<pic.length;c++) { pic[c].id=c; pic[c].onclick=function(){ addTextToTextarea(this.id); } } } function addTextToTextarea(num){ message=['((angry))', '((applause))', '((atwitsend))', '((biggrin))', '((confused))', '((crying))', '((dancing))', '((daydreaming))', '((doh))', '((dontlook))', '((drooling))','((fingers))', '((frustrated))', '((happy))', '((hush))', '((idea))', '((idontknow))', '((laughing))', '((lovestruck))', '((nailbiting))', '((notlistening))', '((notworthy))', '((party))', '((praying))', '((rockon))', '((rolling))', '((sad))', '((secret))', '((shameonyou))', '((surprise))', '((thumbs))', '((thumbsdown))', '((tired))', '((waiting))', '((wave))', '((whew))', '((whistling))', '((worried))']; document.getElementById('ta').value+='\n'+message[num]; } </script> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.