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

Checkbox and onclick event issues

Started by RickJ, 14 Nov 2013 10:25:07 AM

Previous topic - Next topic

RickJ

Hello all!

I've done a lot of reading/searching around this issue and I can't seem to find something that works for me. I'm hopeful you intelligent and kind folk can spot something I'm missing.

I just recently migrated from Cognos 8.4 to 10.2 and I'm working on a report that was fine in 8 but is giving me issues in 10. The basic idea behind this code is to reload the page if certain conditions are met. I have certain rows of a table set to hide/show based on selections made in a check box. This is so that additional information is only captured if the user selects an option that requires it.

I complete this by overriding the onclick event with a function and in the function check if I need to reload the page. I'm trying to minimize the number of reloads required to ease user experience so I only reload the page if I need to show/hide something.

The problem is the checkbox doesn't update to show ticked/blank unless the page reloads. I've tried using the list[2].click event to show it as I've seen suggested by Paul and others, but this doesn't work either. I assume this is because I have replaced the onclick event with something else.

Any suggestions?

<script language="javascript">
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);

if ( !fW || fW == undefined)
{ fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}

var list = fW._oLstChoicesvp_Output_Types;

list[1].onclick = fReprompt;
list[2].onclick = fReprompt;
list[4].onclick = fReprompt;

function fReprompt()
{
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);

if ( !fW || fW == undefined)
{ fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}

var list = fW._oLstChoicesvp_Output_Types;

if (this.value == list[1].value && !list[2].checked)
{
promptAction( 'reprompt' );
}
else if (this.value == list[2].value && !list[1].checked)
{
promptAction( 'reprompt' );
}
else if (this.value == list[4].value)
{
promptAction( 'reprompt' );
}
}


CognosPaul

With the new Prompt API there is a significantly easier way to do this. I'm not at a Cognos install right now, so I can't build or test anything.

You can use the setValidator function on the prompt as the onclick event. The getValues function will return all of the selected values in the prompt in a JSON array. You can loop through that to determine what action needs to take place. Have you seen my old article on the API? http://cognospaul.com/2012/11/05/cognos-prompt-api/

That has most of the functions you'll need. The Prompt API also offers a streamlined way of sending actions to the report: http://cognospaul.com/2013/04/02/button-prompts-in-cognos-10/

You should be able to get what you need from those. If not I'll try to help more on Sunday.

RickJ

Hey Paul,

Thanks for the information! I had looked at your stuff but I didn't really connect the two together. It took a bit of messing around but I seem to have come up with a working solution. I followed mostly what you had posted from Rick Blackwell's example. I haven't used getValues yet so I would still be curious to see what you come up with.

Thanks again!