Forum Moderators: open

Message Too Old, No Replies

adding smiley code to textbox OnClick

doesnt work

         

Gero_Master

8:41 am on Dec 20, 2005 (gmt 0)

10+ Year Member



Hello!

I'm working on an advanced hosting system bsed on PHP. But I need few JAVASCRIPT elements, which I couldn't greate myself.

Thing is... there is a shoutbox. Users should be able to add smileys from a table, by pressing on the smiley image. It would then add a text smiley code after the already written text in the message field.

I have set the smilies outside the form.

form "post"
target textbox "message"

what it should do is "OnClick add " :)" after the already written text in the textbox "message""

Thank you

Tomi

Fotiman

7:06 pm on Dec 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



No time to test it, but you're probably looking for something like this:

<a href="#" onclick="addSmileyCode(':-)');return false;"><span>:-)</span></a>

function addSmileyCode( smileyCode )
{
var msg = document.forms["post"].message;
msg.value = msg.value + smileyCode;
}

I think that's basically what you're looking for (but you probably want to add some error checking, etc.).

Gero_Master

6:54 am on Dec 21, 2005 (gmt 0)

10+ Year Member



Many thanks!

I will try that out today!

Cheers

Tomi