COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: aravind006 on 18 Jun 2015 06:08:09 AM

Title: Clear the value prompt
Post by: aravind006 on 18 Jun 2015 06:08:09 AM
Hi,

How to reset the value prompt values in cognos 10.2.2?
I have added the below code ,but it is not working as expected.

<script>
var list_prompts = document.getElementsByTagName("select");

function ClearSelections(){
  for (var i=0;i<list_prompts.length;i++)
  {
    list_prompts.selectedIndex = -1;
  }
}
</script>

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

Please do the needful.

Thanks & Regards,
Aravind
Title: Re: Clear the value prompt
Post by: qvixote on 18 Jun 2015 03:22:51 PM
I think you should change the line:

list_prompts.selectedIndex = -1;

with:

list_prompts[i].selectedIndex = -1;

Title: Re: Clear the value prompt
Post by: CognosAnalytics on 18 Jun 2015 03:59:02 PM
You are not using the counter anywhere....
for (var i=0;i<list_prompts.length;i++)
  {
    list_prompts.selectedIndex = -1;
  }
}
Title: Re: Clear the value prompt
Post by: qvixote on 19 Jun 2015 07:09:28 AM
That was I meant, but the page replaced the [ i ] since it's used to indicate italized text. You should use this line inside the FOR statement:

list_prompts[i].selectedIndex = -1;