Writing code for an HTML button
After inserting an HTML button in a report, you use the script editor to write JavaScript code that specifies the task to perform when a particular button event occurs. This type of code is called an event handler. HTML button event handlers can consist of any valid JavaScript code, and typically access report data and the Actuate JavaScript API to provide interactive viewing functionality.
The HTML button supports multiple events, and you can write multiple event handlers for a single button to execute different routines based on the event that occurs. For example, you can write an event handler that displays help information when the user moves the mouse pointer over a button, and a second event handler to run a business process when the user clicks the button.
Table 22-1 lists and describes the events that the HTML button supports and for which you can write code.
Table 22-1  
When you select an event for which to write code, the script editor provides a JavaScript code template, as shown in Figure 22-5.
The following line of code in the template instructs the software to execute the code within the braces that follow when a click, or button press, event occurs:
this.onclick = function(event)
Do not modify this line of code. Write your JavaScript code within the braces following that line.
Figure 22-5  
If you write multiple event handlers for an HTML button, the script editor places all the event handlers serially, as shown in the following code example:
/**
 * Occurs when mouse clicks.
* @param event */
 
this.onclick = function(event)
{
  /* onclick code here */
}
 
/**
 * Occurs when a mouse button is released.
* @param event */
 
this.onmouseup = function(event)
{
/* onmouseup code here */
}

Additional Links:

Copyright Actuate Corporation 2012