Archives

Among the properties of most page elements are the Page Field Name and
Enable as Page Anchor properties. These are found on the "General" tab.
I've often wondered what they were good
for. A search in PeopleBooks didn't yield much except statements to the
effect that you can set these properties. Why bother? The only direct
uses for Page Field Name that I know of are as a name for referring to
scroll areas, and as the only way to refer to a grid column in order to
change the column heading label in code. Other than that, setting
Page Field Name just seems to generate a comment within the HTML.

The Enable as Page Anchor property, when selected, simply wraps the
element within <A> and </A> and gives this anchor the name
specified in Page Field Name. That would allow us to jump from one part
of a page to another—probably a fairly uncommon need on PeopleSoft pages.

However, we can combine these two obscure properties and use the combination
for another purpose. Setting both of them will, as I mentioned, wrap the
element within a named <A>. This means that we can refer to this anchor
in JavaScript.

For example, we can add a Group Box (which is essentially a <TABLE>) and
wrap it within an anchor. The anchor has a NAME, not an ID, so we can't
use getElementById() to manipulate it. Instead, we must use
getElementsByName(), which returns an array. (A document can contain
only one element with a particular ID, but many with the same NAME.) Since we
know that there is only one item on the page with the NAME we specified, we
just take the first entry in that array:

var e = getElementsByName("MyName")[0];

This variable can then be used to manipulate the anchor (and the Group Box or
whatever else it may be), or even rewrite its contents completely using the
innerHTML property. Just put an HTML Area object on your page, fill it with your
script, and run the page.

Is this how HTML is supposed to be done? No—but it works. And in many cases
it's cleaner than building all of the HTML within HTML Areas.