Manage Learn to apply best practices and optimize your operations.

SearchTemplate Document Count

One thing you loose when using a $$SearchTemplate to format ?SearchView queries is the "x documents found" notation before the document list. Using Javascript, we can return that information and using the <div> tag we can place it where we want to.
This example has been tested using MSIE 5.0

Using a $$SearchTemplateDefault, place the $$ViewBody field positioned a bit down the page. Below this as HTML include the following:

<DIV style="top:100; left:50; position: absolute; ">
<script>document.write('Your search returned ')</script>
<script>document.write((document.links.length - 3))</script>
<script>document.write(' documents. ')</script></DIV>

The <DIV> tag positions the text "Your search returned x documents." ABOVE the documents returned (which is more readable if a long list of documents is returned). The actual code needs to be below the $$ViewBody so as to be able to count all of the documents (as links).

In this example, I have three hyperlinks used for navigation on the page. By subtracting 3 from the document.links.length value, I return the correct number of documents.

We can also enhance the text by using the QUERY_STRING to display the searched-for text or use an "if" statement to display "document" instead of "documents" if only one document is returned.

The <div> tag is also useful for positioning elements (such as graphics) flush with the left/top instead of using the HTMLHead to set margin values for the entire page which can cause headaches for text display.

This was last published in January 2001

Dig Deeper on Domino Resources - Part 6

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...