jess_ Posted June 21, 2008 Share Posted June 21, 2008 If i were to assign an image the name "book" (for example), and if i clicked on it, how would i script it so the text "book" will appear in a textarea? I'm guessing javascript:void(0) is used in this case... somehow... Pretty much like how you can click on a smilie, and it is replaced by text in the reply-textarea-box. thank you in advance Quote Link to comment Share on other sites More sharing options...
jess_ Posted June 21, 2008 Author Share Posted June 21, 2008 oh yay xD i found it if anyone has the same problem here is the script: Inbetween Head tags <script language="Javascript"> //Set up an array of all the content var clickArray = new Array(); clickArray[0] = "what is to be shown when clicked"; clickArray[1] - "the same thing, but second"; //keep adding as much as you need //the main function to change the content function changeContent(linkNo){ //get a handle for the box object var contentBox = document.getElementById("clickStuff"); //change the innerHTML to the array item contentBox.innerHTML = clickArray[linkNo]; } </script> For indiviual link <a href="javascript:void(0);" onClick="changeContent(0); return false">LINK NAME HERE</a> Textarea code: <textarea id="clickStuff"></textarea> edit: oh wait... something is wrong with it ==" i can't further add more links, when one link is clicked, if i click another one, it won't add on in the text area ??? Quote Link to comment Share on other sites More sharing options...
xtopolis Posted June 21, 2008 Share Posted June 21, 2008 The code can be found by viewing the source of PHP Freaks. If you want to see it without the fat, look: Here javascript:void(0) is actually a null thing. It basically gives the <a> thing no where to go, making it clickable but without the risk of it going anywhere. What actually makes the smiley insert is the call to a javascript function (on this board called: replaceText) which attempts to insert the smiley's equivalent BBC text " " into the text area where your last caret position was. (the caret is the blinking | that you see while typing). Read through their code and you'll understand a little bit. Quote Link to comment Share on other sites More sharing options...
jess_ Posted June 21, 2008 Author Share Posted June 21, 2008 Ahh!! this is totally awesome. i get it!! thank you so much, you really helped me Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.