Tuesday, August 3, 2010

OBIEE Injecting javascript at GO button

Just a piece of script to inject your own javascript at the go button. You can use it fi to check if the user made a “valid” selection.

[code]

<script type="text/javascript">
function getElementsByClass( searchClass, domNode, tagName)
{
    if (domNode == null) {
    domNode = document;
    }
    if (tagName == null) {
    tagName = '*';
    }
    var el = new Array();
    var tags = domNode.getElementsByTagName(tagName);
    var tcl = " "+searchClass+" ";
    for(i=0,j=0; i<tags.length; i++) {
        var test = " " + tags[i].className + " ";
        if (test.indexOf(tcl) != -1)
        {
            el[j++] = tags[i];
            if (tags[i].innerHTML.indexOf('DoFilters') > 0 )
            {
            tags[i].innerHTML = tags[i].innerHTML.substring(0, tags[i].innerHTML.length - 7 )
                             + " onfocus=javascript:alert('Put your javascript here'); >Go</a>"
            alert (tags[i].innerHTML);
            }
        }
    }
    return el;
}

</script>

<script type="text/javascript">

    var tabs = getElementsByClass('minibuttonOn');
</script>

[/code]

Add the code in a textbox after the prompts, don’t forget the contains HTML checkbox.

Till Next Time

2 comments:

Unknown said...

Hi John, massively useful post.

Any chance of making it unbelievably useful by adding a brief but perfectly formed example of how to get data based validation in there??


Thanks,

Robert.

SS said...

Hi, Is there any way to hide Edit button in a multiselect prompt ?