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

Pop Up Window or Message when All Values Are not Chosen

Started by Grayson_Basil, 10 Aug 2016 08:46:49 AM

Previous topic - Next topic

Grayson_Basil

I have a report which has 6 prompts, 4 of the 6 have default values, the remaining 2 need the Account ID and Year.  My execs dont understand that both have to be filled in so I have been asked to create a pop up window message alert as to which one or two of the 2 prompts needs a value.  The red asterisks is not sufficient and they are requesting a pop up message of some sort.


AnalyticsWithJay


Grayson_Basil

im on 10.2.1 and this simply code does not work

dropdown box is called mydropdown
2 static values, 2015,2016

<script LANGUAGE="JavaScript">
<!–
// call Cognos built-in function to get the form element
var fw = getFormWarpRequest();
//get the drop down element
var dropdown=fw._oLstChoicesmydropdown;
//next will loop through all the options of the drodown lis
for (var i=0; i <dropdown.options.length; i++)
{
if (i >1) //skip the first two default options Cognos generated
alert (dropdown.options.text) ; //call alert function to display the text value of the option
}
//–>
</script>

Grayson_Basil

I was able to get a check working, however, I belive there has to be a loop to check all of the values in the radio box. This is working however, for each item in the radio box, a pop up window occurs.  I just need the popup window 1 time

take a look
function radioSelect()
{
     // get the handle for the 1st radio prompt - add div around them to distinguish
      var prompt1 = document.getElementById('radioBox1');

      var node_list = prompt1.getElementsByTagName('input');

      for (var i = 0; i < node_list.length; i++)
      {
         var node = node_list;
         if (node.getAttribute('type') == 'radio')
         {
               if (node.checked ==false )
               {   
                 //  alert("Selected #" + i + " Value= " + node_list.value);
alert("Please Selected");
               }
          }
      }
}



</script>

Lynn

Quote from: Grayson_Basil on 10 Aug 2016 08:46:49 AM
I have a report which has 6 prompts, 4 of the 6 have default values, the remaining 2 need the Account ID and Year.  My execs dont understand that both have to be filled in so I have been asked to create a pop up window message alert as to which one or two of the 2 prompts needs a value.  The red asterisks is not sufficient and they are requesting a pop up message of some sort.

Rather than a pop-up with JS, could you revisit the layout and content on the prompt page to include informative messages? It sounds like your execs are less computer-savvy than some 70-year-olds I know if they can't understand that a greyed out run button and prompt interface adornments mean a response is required. Assuming they are able to read perhaps a label would suffice to help them figure out what to do.

AnalyticsWithJay

Sorry, a little late responding to your previous post, but nice job and getting this far.

Add a variable above the "for" loop like:
var passedValidation = true;

Then, replace the "alert()" code with:
passedValidation = false;

Then, after your "for" loop, add:
if (passedValidation == false)
{
    alert("message goes here");
}

Grayson_Basil

#6
Thanks Jay, I believe we were thinking the same thing

Here is the final JS for anyone needing help.  This is working great for me on 10.2.1
Im sure there is a much cleaner way of doing this, but hey, this is working! 

I have added 4 HTML items
<div id="radioBox2">
Radio Button - Cognos Value Prompt
</div>
<html with the code below>
<button type="button" name="Submit" onClick="checkNumSelected()">Submit</button>


<SCRIPT LANGUAGE="JavaScript">

// use the function whenever available
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);

function checkNumSelected()
{



isChecked ()
}


function radioSelect()
{
     // get the handle for the 1st radio prompt - add div around them to distinguish
      var prompt1 = document.getElementById('radioBox1');

      var node_list = prompt1.getElementsByTagName('input');

      for (var i = 0; i < node_list.length; i++)
      {
         var node = node_list[i];
         if (node.getAttribute('type') == 'radio')
         {
               if (node.checked ==true)
               {
                   alert("Selected #" + i + " Value= " + node_list[i].value);
               }
          }
      }
}


function isChecked ()
{
     // get the handle for the checkbox prompt - add div around them to distinguish
      var prompt1 = document.getElementById('radioBox2');

      var node_list = prompt1.getElementsByTagName('input');
var r = 0;
//alert (r);
    for (var i = 0; i < node_list.length; i++)

     {
         var node = node_list[i];
         if (node.getAttribute('type') == 'radio')
         {
              if (node.checked ==true)
                {   
     r++;

//promptButtonFinish();
//return true;
}

        }

    }

if (r < 1)
{alert ("Report Totals Not Selected")}
else {promptButtonFinish();}
}


</script>





Michael75

QuoteWhich part of the JS code do you need help with? Here's a handy tutorial to get you started:

http://cognosfaq.blogspot.ca/2012/12/ibm-cognos-and-javascript-examples-and.html

I'm a bit late to the show here, but I'd like to point out that the charming Mr Mandala, whose blog this is, lifts his content wholesale and without attribution from the Ironside Group site.

The article referenced, by Susan Ma of Ironside, can be found here:

https://www.ironsidegroup.com/tag/javascript/