If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

if a search and select box can be defaulted to show all the query values

Started by Wild Klaus, 27 Dec 2008 05:14:48 PM

Previous topic - Next topic

Wild Klaus

Hi,
Does anyone know if a search and select box can be defaulted to show all the query values prior to running a search. Like the way a list box shows all query values prior to selection.

Thanks

Sunchaser

Hi,
Depending on which version (8.2 or 8.3) you use, it could be more easier or not.
The only method I know is by using javascript in HTML Item, but I might be wrong and someone else could have a better idea.
In 8.2, you can catch the textBox for the "searchValue" easily but in 8.3 it's a little bit more "funny"...

First just before the "Search and Select Value" prompt, put an HTML Item containing this:

<div id="myDiv">


The after the "Search and Select Value" prompt, put an HTML Item containing this:

</div>


<script>
//get our DIV
var baseObj = document.getElementById("myDiv");

//find the textBox and change value
var ipt = baseObj.getElementsByTagName("INPUT");
if (ipt != null) {
for (var i = 0; i < ipt.length; i ++)
{
if (ipt[i].getAttribute("name")=="_searchValue")
{
ipt[i].value = "%";
}
}
}
</script>


At the end of the page, I put an other HTML Item, just for:

<body onload="init()"></body>


At the very beginning of the page, I put the last HTML Item:

<script>
function init()
{
//get search Button
var btn = baseObj.getElementsByTagName("BUTTON");
btn[0].click();
}
</script>


So, the value in the textBox is changed, and the "startSearch" button is like "clicked".
It's just a test, and everything could be written in a better way of course.
If you use this idea, don't forget to catch error (try / catch) for example and / or make sure that objects targetted are really existing in the page at the moment you want them.

Hope it could help,
Vinc.

Wild Klaus

Thank you very much!
It works!

May be you know answer on another question…
How can I call one more javascript function _after_ “Search and Select Value” has loaded?
If I put it in function init() after btn[0].click() then firstly my function is executed, and later “Search and Select Value” loaded with values.




Sunchaser

Hi,

Glad to see that the few lines of code helped you.

For the last question, I must say that it won't be easy for me (hope we'll have some help for someone else of this forum, maybe).

My first idea was to do an "attachEvent()" on the list that is receiving the datas.
It's not so hard to get it because it is the first object with the type "SELECT" in this "search and select" prompt object.
The problem is to work on the good event, if it is available.
I've tried with "onAfterUpdated" or things like that, but it seems that it was a bad idea.

I'll be back later on your post if I've something better.

Sunchaser

Hi Wild Klaus,

May be I have a solution, but be carefull it is not a very "clean" code as it will use a timer and a loop (and don't like this idea but I haven't found anything else.
So you'll have to change this code:

<script>
function init()
{
//get search Button
var btn = baseObj.getElementsByTagName("BUTTON");
btn[0].click();
}
</script>

by this new one:

<script>
var timer, sl, keepTesting = true;
function chkSelect()
{
if (keepTesting == true)
{
if (sl[0].length > 0)
{
doSomething();
}
}
else
{
clearTimeout(timer);
}
};

function doSomething()
{
alert('oki');
clearTimeout(timer);
};

function init()
{
//get search Button
var btn = baseObj.getElementsByTagName("BUTTON");
btn[0].click();
}
</script>

And this code:

</div>


<script>
//get our DIV
var baseObj = document.getElementById("myDiv");

//find the textBox and change value
var ipt = baseObj.getElementsByTagName("INPUT");
if (ipt != null) {
for (var i = 0; i < ipt.length; i ++)
{
if (ipt[i].getAttribute("name")=="_searchValue")
{
ipt[i].value = "%";
}
}
}
</script>

By this one:

</div>


<script>
//get our DIV
var baseObj = document.getElementById("myDiv");

//find the textBox and change value
var ipt = baseObj.getElementsByTagName("INPUT");
if (ipt != null) {
for (var i = 0; i < ipt.length; i ++)
{
if (ipt[i].getAttribute("name")=="_searchValue")
{
ipt[i].value = "%";
}
}

sl = baseObj.getElementsByTagName("SELECT");
if (sl[0] != null)
{
//sl[0].attachEvent("onreadystatechange", function(){ alert('oki'); }
// );
timer=setTimeout("chkSelect()", 500);
}

}
</script>


You can play with the interval of the timer of the setTimeout function, if needed.
Not really "clean", but could do it.

Hope it could help you.
vinc.