Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript in Report Net - Rob can help me 1

Status
Not open for further replies.

pradev

Programmer
May 17, 2006
10
US
Hello Rob,

you said in the earlier thread you got that javascript in Cognos site. Where to find the doc on Java Script in HTML item.

Here is my problem, I have two text prompts which takes numbers. After clicking Submit I need to compare these two values and display an alert. I think this can be done only thro Javascript. Help me out.

Regards,
Prapagar
 
I could able to resolve this problem.
 
Good morning-

It was an article in Supportlink:
You need to have an account on cognos's support site to view it. It really doesn't explain what they are doing; it just gives you a script similar to what I previously posted. I haven't found anything that explains how to use Javascript in general, but you can find some other documents by searching for 'Javascript' in the knowledge base.

I believe you are right that this is a case where you would use Javascript. In fact, that would be only a slight modification to the script I previously posted. This code uses to textbox prompts with parameters TEXT_1 and TEXT_2.

Code:
<script>

var cntlName;

// Function to check prompts before submission
function customCheckPage()
{
    var numVal1;
    var numVal2;

    fillCount = 0;
    for( var i=0; i<preProcessControlArray.length; i++)
    {
        cntlName = eval(preProcessControlArray[i]);

        if (cntlName.m_oSubmitField && cntlName.m_oSubmitField.name.toLowerCase() == 'p_text_1' )
        {
            cntlName.m_oFormField.lostFocus;
            if(cntlName.m_oFormField.value.length >0)
                numVal1 = Number(cntlName.m_oFormField.value);
        }

        if (cntlName.m_oSubmitField && cntlName.m_oSubmitField.name.toLowerCase() == 'p_text_2' )
        {
            cntlName.m_oFormField.lostFocus;
            if(cntlName.m_oFormField.value.length >0)
                numVal2 = Number(cntlName.m_oFormField.value);
        }

    }
    
    if (isNaN(numVal1))
    {
        alert('Value 1 must be numeric.');
    }
    else if (isNaN(numVal2))
    {
        alert('Value 2 must be numeric.');
    }
    else if (numVal1 >= numVal2)
    {
        alert('Value 1 must be less than Value 2');
    }
    else
    {
        promptButtonFinish();
    }

}

// Find 'Finish' Button and replace submit method with custom function above
for( var i=0; i<pageNavigationObserverArray.length; i++)
{

    cntlName = eval( pageNavigationObserverArray[i] );
    
    if(cntlName.m_oParent.onclick.toString().indexOf('promptButtonFinish()')>0 )
    {
        cntlName.m_oParent.onclick = customCheckPage; 
    }
}
</script>

I haven't done Javascript in a while, so this may need some tweaking to work, but it should give you the idea.

Hope this helps!

--Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top