Jump to content

Insert Smiley Code, Need a Tiny Bit of Help


liquidspaceman

Recommended Posts

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:  :P

 

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>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.