Need help with Javascript!

Started by
1 comment, last by shawnmos 22 years, 4 months ago
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.... http://www.shawnscomputers.com/forums/messageview.cfm?catid=17&threadid=6567 for a better idea of what I am trying to do.
Advertisement
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.
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.

Example:
<.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 http://www.htmlgoodies.com








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


Edited by - BugTilaheH on December 11, 2001 5:38:31 PM
-Bug/********************************** Website: The Page of Stuff.COM ** Message board: POS.COM Forum   **********************************/

This topic is closed to new replies.

Advertisement