Hi All,
How to get dynamic max year(ex:2008) as default selection in the value prompt when i run the report.
Regards,
Anand.
Hi,
U can do that using javascript. Get the values from listbox in a array and sort the array elements. Once u got the max value from array assign that value to listbox selected item. Please let me know if u need more info.
I can post the code tomorrow if u want.
HTH
thanks
Hi Satish,
Thanks for sending the reply and i am displaying that value prompt in the report page itself and they are in sorting order only(2006,2007,2008,2009,2010) and please send me the java script and when i run the report it should display by current year and after that we can change that from the prompt available in the report header.
Regards,
Anand.
Hi Anand,
Please see the following script for ur solution.
---------------
var lb = document.getElementById('formWarpRequestRS')._oLstChoicesXXX;
arrTexts = new Array();
for(i=0; i<lb.length; i++) {
arrTexts = lb.options.text;
}
arrTexts.sort();
var len=arrTexts.length-1;
document.getElementById('formWarpRequestRS')._oLstChoicesXXX.options[len].selected=true;
---------------
Where XXX is the name of the Value prompt. Sorry for the delay. I was travelling and did not access the forum.
Quote from: kattaviz on 20 May 2008 02:59:11 PM
Hi Anand,
Please see the following script for ur solution.
---------------
var lb = document.getElementById('formWarpRequestRS')._oLstChoicesXXX;
arrTexts = new Array();
for(i=0; i<lb.length; i++) {
arrTexts = lb.options.text;
}
arrTexts.sort();
var len=arrTexts.length-1;
document.getElementById('formWarpRequestRS')._oLstChoicesXXX.options[len].selected=true;
---------------
Where XXX is the name of the Value prompt. Sorry for the delay. I was travelling and did not access the forum.
If u already sort the query for the prompt then u do not need to sort the array in javascript code. remove the line "arrTexts.sort();"
And if you sort descending you don't need any logic to determine the list size, just select the first element.
Hi,
Does the javascript code posted here works in Cognos 8.3??
Thanks