JavaScript Functions

To use these function, you must know some convention about the HTML elements identifiers generated by ERW. This is necessary, as to create useful hooks you need to be able to detect which row of a table the user selected.

Each relevant HTML element in a page generated by ERW has a well-defined identifier. In particular, whenever a list of elements is displayed to the user, the corresponding table has an identifier (in the XML sense) generated by prefixing a letter followed by the underscore character to a table name. More precisely:

Said that, you can use the following functions to discover which element of a list has been selected by the user:

int getSelectedId(elemId);

Given the identifier of a list, this function returns the SQL identifier (i.e., the value of the id column) of the selected element.

int getSelectedItem(elemId);

Given the identifier of a list, this function returns the 0-based index of the selected row.

void openServiceWindow(url, name);

This function opens a new window without toolbar, menus, etc. and loads it with the given URL. The given name will be juxtaposed to the current number of milliseconds to generate a name for the window, so that two activations of the same button actually open two different windows.

You should look at the example given in the Section called The Button Hook in the Chapter called Customisation.