It is possible to add a Table of Contents to a view that has to accept parameters1.
In this case, you do not want to use the solution of including the view in a node (with the Insert view filter, see Can't find doc_table_of_contents_for_views to include!) because then you lose the capability of assigning different parameters to your view (although, if the number of parameters is relatively limited, you could create one page per set of parameters supported.)
So, here, we offer a solution for you to include a Table of Contents using your view template. Basically, it reformats the view output by passing it through the Table of Content filter. The filter requires a format number and the text to be filtered.
<?php
module_load_include('pages.inc', 'tableofcontents');
echo _tableofcontents_replace_toc(2, '[toc]'.$rows) ;
?>
These two lines of code will prepend a Table of Content to the $rows text. The $rows text comes from the Views.
To append a Table of Contents, simply move the '[toc]' string after the $rows reference as in: $rows.'[toc]'
The module_load_include() call is necessary in case the tableofcontents.pages.inc file was not loaded.
The number 2 in the call to the _tableofcontest_replace_toc() function is the format identifier. The one main reason why you'd want to enter a specific format is to gain the flexibility of changing the Table of Content setup from the Drupal interface (from your Administer » Site configuration » Input format settings form.) Use the number 0 if you just want to use the default settings and what you specify in the view template, since it is possible to include parameters along the [toc] tag such as the title.
<?php
module_load_include('pages.inc', 'tableofcontents');
echo _tableofcontents_replace_toc(0, '[toc title:My View; minlevel: 2;]'.$rows) ;
?>
In this example I show how the table can be given the name My View and use <H2> as the minimum level.