Friday, January 13, 2012

Clear Value Prompt Selections Using Javascript

Business Case:
User wants a clickable link on the prompt page to clear all prompt selections.

Environment: Cognos 8.4, Report Studio, Javascript, Mozilla Firefox / Internet Explorer

This can be achieved using Javascript.
  • Place an HTML item at the end of the prompt page after all the prompts.
  • Place the code from the next section into the HTML item.
  • You can use a table to position the link on the page.
  • When the report is executed, user will see a link "Clear All Selections", which will reset all the prompt selections.
var list_prompts = document.getElementsByTagName("select");

function ClearSelections(){
  for (var i=0;i<list_prompts.length;i++)
    list_prompts[i].selectedIndex = -1;

<a href="JavaScript:ClearSelections()">Clear All Selections</a>


  1. Thanks for the solution sriram it worked with 8.4 as well as 10.1. Great work.

  2. Hi Sriram,
    This only works for the value from prompt.
    How about if you have a check box value prompt it seems like it does not work with that.
    Could you please post something which will clear the values from the check box multi-select value prompt.
    I will really appreciate it.

    1. did you manage to get a solution for the checkbox?

  3. How can we make this work for search & select prompt

  4. This is great. Is there a way to modify this code for 2 value prompts. If one value prompt is selective, the other prompt reset/clear.
    I will greatly appreciate it.

  5. The lure of transforming one's body into something truly enviable along with other immediate gains of performance leads many people to steroids side effects.visit site

  6. thanks for this usefull article, waiting for this article like this again. napsgear