Jump to content

[SOLVED] Javascipt Void(0)


jess_

Recommended Posts

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  ;D

Link to comment
Share on other sites

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  ???

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.