Javascript Functions

This script creates a variable and a 
FUNCTION that puts the variable into the
form field.

Functions are blocks of code that perform
certain actions; they can be "called", that is, 
they perform the action upon request--repeatedly,
if necessary.
  
In this example, the function is called
by the onload event handler in the <body> tag

The onload event handler calls the function showMe() 
and sets the value of the form field.
    

Result:

Value of Variable:

The code:

<script language="JavaScript">
<!-- 
  
var displayString = "[variable]";
  
function showMe()
{

/*  Object hierarchy:

    document = container that holds everything displayed in
               the browser window
    forms    = the array of forms maintained by 'document'
    form1    = ID of the form set by an HTML attribute
    output1  = name (HTML attribute) of input field in 'form1'
    value    = contents of 'output1'                         */
    
    document.forms.form1.output1.value = displayString;
    return true;
 }
  
 // -->
 </script>