onClick Handler
An element's onClick handler is executed when a “selection” event (i.e., mouse click) takes place on the element. You can use the onClick handler to implement interactions such as hyperlinks and drilldowns, or to initiate any other business logic in response to user selections.
To access the onClick handler for an element, right-click the element, and select 'Script' from the context menu. Then select the onClick tab at the top of the Script Editor.
Figure 5. The onClick tab of the Script Editor
Using the onClick Handler
Because the handler does not execute on the client browser, it cannot perform client-side actions directly. Instead, the handler controls the behavior of the report by returning one of the pre-defined viewer actions. Actions related to hyperlinks are showReplet() and showURL(). Other viewer actions are discussed in a later chapter.
Note: The viewer action functions (showReplet, sendRequest, etc.) should be the final statement of the onClick script.
The onClick handler is primarily used for Tables and Text elements, in situations where you cannot completely define the hyperlinks at design time. For example, if a hyperlink is required to pass parameters that might change as a result of user interactions, you can compute the parameter values in the onClick handler, and then create the hyperlink by using the showReplet() action.
For example, consider the following onClick script attached to an element. When the user clicks the element, the script tests a condition, and then loads one of two possible reports.
if(condition) {
showReplet("order info",[["start_date",CALC.today()]]);
}
else {
showReplet("customer info",[["state", "NJ"]]);
}