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

Attaching JavaScript onclick to list prompt

Started by bmccall, 02 Sep 2016 12:44:54 PM

Previous topic - Next topic

bmccall

My report prompts users to select three different criteria (which are cascaded).  Once those criteria are selected, a list prompt is populated by other values.  I have a text box prompt to store values from the list prompt so other values from different criteria can be selected and used in the generated report.  Right now, users need to manually enter the value that appears in the list prompt to put it into the text box prompt.  Wondering if there is a way to using JavaScript to populate the text box prompt when a user clicks on a value in the list prompt.  Here's what I've tried:

<script LANGUAGE = "JavaScript">

var form = getFormWarpRequest();
var myList  = form._oLstChoicesn1  //n1 is the name of the list prompt
var myBox  = form._textEditBoxn2  //n2 is the name of the text edit prompt

myList.onclick = function() {myFunction()};

function myFunction()
{
     for(var i = 0; i < myList.options.length; i++;)
     {
          if(myList.options.selected)
          {
                    myBox.value = myList.options.text;
                    return;
          }
     }
}
</script>   

I've attached a picture of the set up.  The red box is the list prompt, and the black and blue boxes are the text edit prompt. 

When I set myBox.value (assuming everything else works), is it the value of the black box or blue box?

Thanks in advance for the help.  I'm using 10.2.2

AnalyticsWithJay

I would go about this slightly differently, but primarily out of personal preference.

1. Place a list box which contains all your values. Multi-select. No cascades. Hidden (box type = none).
2. Beside your cascading prompts, have a button that once clicked, will traverse the hidden list box, and if the value matches that in the hidden list, select the value in the hidden list. The button will also re-prompt, clearing the cascade, but keeping the values in your list.

Let me know where you are with your javascript and I'll give it a try during my free time.

Jay

bmccall

Thanks Jay, I'll look into this and run it by the business and see if that will work with their needs and requirements.  The only issue I see with this is that since the box is hidden, they wouldn't be able to see what was selected, unless there was a way for the JavaScript to only show was has been selected and group the selected items at the top.

AnalyticsWithJay

Quote from: bmccall on 16 Sep 2016 12:20:32 PM
Thanks Jay, I'll look into this and run it by the business and see if that will work with their needs and requirements.  The only issue I see with this is that since the box is hidden, they wouldn't be able to see what was selected, unless there was a way for the JavaScript to only show was has been selected and group the selected items at the top.

You're welcome. There's a CSS property of 'disabled'. You can assign this property to the box so that the user cannot edit its contents while it remains visible:

http://www.w3schools.com/jsref/prop_html_disabled.asp