Server-Side JavaScript
The server-side 'onClick' script has access to a RepletRequest Object containing all form element values. You can access a particular field value by using the element 'Field Name' as index:
request['FieldName'] or request.FieldName
Field names must be unique within a form (with the exception of Radio Buttons).
If there are multiple “submitting” form elements, use 'request.__eventSource__' to obtain the field name of the element that triggered the submit action. For example:
if(request.__eventSource__ == 'Choice1') {
...
}
else if(request.__eventSource__ == 'Button1') {
...
}
else {
...
}
Note: If the 'onClick' script of a form element on a Parameter Sheet calls the sendRequest() function, the submission from sendRequest() is sent in place of the normal form submission request.
If your script modifies element values and needs to refresh the screen, it should call the reprint() or refresh() function. The 'reprint' action causes the report pages to be regenerated without refreshing the data binding. The 'refresh' action forces the report data to be refreshed before the report is reprinted. If the onClick Handler does not change the data or the way the data is bound to report elements, the reprint action is sufficient.
The following sample code is taken from the form.srt report in the examples/docExamples/script directory. The script checks various form field values, and sets report characteristics appropriately.
Note: Set your Repository location to examples/docExamples/script. See Configuring and Selecting a Repository in Getting Started for instructions.
if(request['values']) {
Chart1['value.visible'] = true;
}
else {
Chart1['value.visible'] = false;
}
switch(request['hGrid']) {
case '(none)':
Chart1.yGridStyle = Chart.NONE;
break;
case 'Thin Line':
Chart1.yGridStyle = Chart.THIN_LINE;
break;
case 'Dot Line':
Chart1.yGridStyle = Chart.DOT_LINE;
break;
}
Figure 7. Form Example (form.srt)

| << Scripting the onClick Handler | © 1996-2013 InetSoft Technology Corporation (v11.4) | Appendix SI: Style Intelligence Object Reference >> |