The following is the onClick event handler for a button that displays the next page on a form. If the last page is displayed, the button is disabled.

function nextButton_onClick( )

   if ++form.pageno >= form.pageCount( ) // Goto next page, and if it's the last page 

      this.visible := false // You can't go any further 

   endif