2021.2

Table Of Contents
These functions are used by the Conditional Script Wizard, as you can see when you open a
Conditional Script and click the Expand button; see "Showing content conditionally" on
page815.
Example
This script hides or shows the elements matched by the selector of the script (which are stored
in the results object), depending on the value of the data field Country in the current record.
if (record.fields["Country"] == "CANADA") {
results.show();
} else {
results.hide();
}
tagName()
Returns the HTML tag name of one HTML element in uppercase (e.g. H1, P, ARTICLE).
Example
This Post Pagination Script finds level 1 and 2 headings in all Print sections and stores their
page number, text and HTML tag name.
merge.context.query("h1, h2").each(function() {
var pageNo = this.info().pageNo;
var text = this.text();
var level = this.tagName();
});
This code is used in a script that inserts a table of contents. For the full script and explanation
see "Creating a Table Of Contents" on page931.
text()
text() : String
Returns the text content of an HTML element or of the first element in a result set (see "results"
on page1448).
Page 1402