©ilj@flowsim.se
JavaScript onClick / images / textarea
how to display text in a TEXTAREA when you click on an image
document.a_form.a_textarea.value='text text text'
>>> this example in Swedish
 
 

1 2
Click on the pitures!


 
code & explanations below

   


 
Put a TEXTAREA on a FORM and name them, like this for instance :
 
<FORM NAME = "iljtextareaform1">
<TEXTAREA NAME = "
iljtextarean2"
ROWS = "8"
COLS = "30"
WRAP = "physical">
</TEXTAREA>
</FORM>
 
Here are the tags for two clickable images:
 

<A HREF = "#"
     ONCLICK="
iljtextval(1);return false"
     ONMOUSEOUT="
iljtextval(0)">
<IMG SRC= "image file"
     WIDTH = "width of image"
     HEIGHT = "height of image"
     BORDER="0"></A>
 
<A HREF = "#"
     ONCLICK="
iljtextval(2);return false"
     ONMOUSEOUT="
iljtextval(0)">
<IMG SRC= "image file"
     WIDTH = "width of image"
     HEIGHT = "height of image"
     BORDER="0"></A>
 
Clicking on one of the images will call the function iljtextval(textnumber). The number within parentheses keeps track of what text to display and will enter the function as textnumber. Put the function within SCRIPT tags in the HEAD portion of the document (see MINIMANUAL 1 basics):
 

function iljtextval(textnumber)
{
text = new Array()
text[0] = ""
text[1] = "Text for picture number 1"
text[2] = "Text for picture number 2"
document.iljtextareaform
1.iljtextarean2.value= text[textnumber]
}
 
Do not forget to remove the footnotes!
text[0] is used to empty the TEXTAREA when the mouse pointer leaves an image.
 
1 The name of the FORM
 
2 The name of the TEXTAREA
 
 


OTHER JAVASCRiPT EXAMPLES
 
How to use javascript to choose what image to show by selecting it in an option list
How to use javascript to switch images
How to use javascript to switch images onmouseover
JavaScript getDay() and document.write
JavaScript date
JavaScript timer
How to use javascript to switch images onmouseover
JavaScript timer
JavaScript onmouseover
JavaScript lastModified
JavaScript/ text in text area
JavaScript/ text in text area
how to open new windows in JavaScript
JavaScript clock
JavaScript confirm
JavaScript alert
JavaScript prompt
JavaScript onmouseover
JavaScript onmouseover2
JavaScript animation
JavaScript animation 2
 

Page by
ilj
ilj@flowsim.se
Last modified: February 19, 1998
This page should be part of a frames system
at:
http://www.flowsim.se
JAVASCRiPT