View Full Version : Javascript Question

01-25-2005, 06:16 PM
Hey everyone the question I have is I am creating my own message board and I want to be able to click on a smiley face and have it automatically inserted into my message body, but I don't want to limit it to just smileys. I would like to be able to do it for any graphic I have in the directory. I was able to get PHP to create an array of these images and display them but I can't figure out the javascript to get it to insert them when clicked on.

Any help would be great.

Philip M
01-25-2005, 07:08 PM
JavaScript cannot do this - you need a server-side language (such as PHP).

01-25-2005, 07:12 PM
correction, JS _can_ do this... unless I misinterpreted what you mean then Phillip M would be right.
you want a popup window where you click on a smilie and it will insert the smilie text, e.g., :smilie:?

01-26-2005, 04:41 AM
basically we have a message board and I want to list a bunch of graphic in a table or something similar and then have the ability to click on the image you want and have it automatically inserted into the post you are writing. Our current system does this and I believe it is through javascript but I am having trouble recreating it. The current system is in asp and it is old and hard to update and always breaks so were are rewriting everything in php.

here is the old code:
<img src="<%=strPath & objItem.Name%>" onClick="javascript:document.forms.MessageForm.Body.value = document.forms.MessageForm.Body.value + ' <img src=<%=strPath & objItem.Name%>> '">

This code works

New code:
<img src="images/Smileys/{$smileys[i]}" onClick="javascript:document.new.body.value = document.new.body.value + '{$smileys[i]}'">

This new code is in a loop the smiley doesn't have the path to it yet but it isn't inserting anything for some reason.

I was just wondering if anyone could see something i am doing wrong or knows of another way to do this. the old site doesn't have a pop up window for you to click on the image they just show up below the text box.