Adding HTML buttons to a report
 
 
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 19‑1 lists and describes the events that the HTML button supports and for which you can write code.
Table 19‑1 Supported events 
Event
Description
onblur
Occurs when the button loses focus, or stops being active
onclick
Occurs when the button is clicked
ondblclick
Occurs when the button is double-clicked
onfocus
Occurs when the button gets focus, or becomes active
onkeydown
Occurs when a keyboard key is pressed
onkeypress
Occurs when a keyboard key is pressed and released
onkeyup
Occurs when a keyboard key is released
onmousedown
Occurs when a mouse button is pressed
onmousemove
Occurs when a mouse pointer moves when it is over the button
onmouseover
Occurs when a mouse pointer moves onto the button
onmouseup
Occurs when a mouse button is released
When you select an event for which to write code, the script editor provides a JavaScript code template, as shown in Figure 19‑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 19‑5 Script editor displaying a script template
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 */
}