results

The results object (type: QueryResults) is the result of the query for HTML elements that match the selector of the script. The selector of a script can be specified in the Script Editor and is visible in the second column of the Scripts pane, next to the name of the script.

If, for example, a script would have the selector p.onlyCanada, the script would apply to all paragraphs that have the class onlyCanada. (Classes can be defined in the Attributes pane at the right: select the element in the content and type the class(es) in the Class field.)
The script could then use the results object to hide or show those paragraphs, depending on the value of the data field Country in the current record:

if (record.fields["Country"] == "CANADA") {
results.show();
} else {
results.hide();
}
This object can't be used in Control Scripts, because they don't have a selector.

Property

Field Type Description
length

Number

Number of elements in this result set. Equivalent to calling size().

Functions

The functions below can be called by the results object and by any other result set that is returned by a query, see ​​query().

Function Description
add()

Adds elements to a set of HTML elements.

​​addClass()

​​Adds the specified class to each element in a set of HTML elements. Has no effect if the class is already present.

after() ​​Inserts content after each element in a set of HTML elements..​
append()

Inserts content at the end of each element in a set of HTML elements.

attr()

Change the given attribute of the element or set of HTML elements with the given value.

before() ​Inserts content before an element or before each element in a set of HTML elements.
​​children()​​ ​Returns the immediate children of an HTML element.
clone() Returns a new result set containing a copy of each element in a set of HTML elements.​

closest()

For each element in a set, this function gets the first parent element that matches a selector, by testing the element itself and traversing up through its ancestors in the DOM tree.

css() Gets the value of a style property for the first element in set of HTML elements or sets one or more CSS properties for every element in a set of HTML elements.

empty()

Removes the contents (child elements and inner HTML) from one element or a set of elements in the template.

filter()

Returns a subset of the current result set.

find()

Performs a search for a text in the children of each element in a set of HTML elements, and returns a new result set with elements that surround the occurrences.

hasClass() Returns true if the first element in this result set has the specified class.

hide()

Hides the HTML element or set of HTML elements.

html()

​Replaces the inner HTML of the element or of each element in a set of HTML elements with the supplied value, or returns the HTML of the first element if no value is supplied.

is(selector) Returns true if at least one of the elements in a set of HTML elements matches the supplied CSS selector.
pageRef()

Returns a marker that will be replaced with the element's page number after pagination. This only works for elements in the section that is currently being merged.

parent() Returns the parents of the elements in a set of HTML elements.
prepend() ​Inserts content at the beginning of an HTML element or of each element in a set of HTML elements.
​​remove() ​Removes an HTML element or a set of HTML elements from the document.
removeAttr() Removes the specified attribute from each element in this result set.
removeClass() Removes the specified class from an element or from each element in a set of HTML elements. Has no effect if the class is not present.

replaceWith()

Replaces an HTML element or a set of HTML elements (with a snippet, for example). Returns the result set.

show() Shows the HTML element or a set of HTML elements.
size() Gets the number of elements in this result set. Equivalent to the length property.
​​​text() Replaces the text content of an HTML element or of each element in a set of HTML elements with the supplied value, or returns the text content of the first element if no value is supplied.​
 
  • Last Topic Update: 29, June, 2017 08:33 AM
  • Last Published: 23, May, 2019 01:55 PM