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


Need help with Javascript!

Recommended Posts

How do I make it so when you click on an image it places text into a messagebox? For example, I am modifing my forums and I want to make it so when you click a smiley it places the text needed to be entered to get that smiley. Go here.... for a better idea of what I am trying to do.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
You need to set an whenclickedon handler of some kind - whether through the document object or through a link - the document object might be a better approach to take since the target form will likely be more easily accessible that way as well - that is assuming that by ''message box'' you mean a form element. Once you have the clicker going, transfer what ever text you want to the form or if you would rather a ''message box'' just use Confirm or one of the associated calls to instance a built in popup.

Share this post

Link to post
Share on other sites
In your java-script code, create a function that passes a value to the form element:

function handlevalue(val) {
document.nameofform.nameoftextbox.value = val;

Then in the form, have the picture you want the user to click on
with the link and add java-script:handlevalue('value here') to the a href tag.

<.a href="java-script:handlevalue('value here')"><.img src="urlofpic"><./a>

Of course, take out the periods and the hyphen in java-script..

Eh.. some of that might be wrong.. I'm a little rusty on my scripting.. for more info check out

* Website: The Page of Stuff.COM *
* Message board: POS.COM Forum   *

Edited by - BugTilaheH on December 11, 2001 5:38:31 PM

Share this post

Link to post
Share on other sites