COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: richard@AA on 26 Apr 2012 12:35:48 PM

Title: HTML Reprompt Button With JS Error Checking
Post by: richard@AA on 26 Apr 2012 12:35:48 PM
I want to have a reprompt button on the output page, but I need to do error checking between two drop down prompts when they click the reprompt button. I'm guessing I need a HTML manuel built reprompt button. The two drop down prompts are for start and end dates. The error checking I want to do is to make sure they don't have the end date before the start date. Again, these are drop down prompts that happen to have dates in them and not date prompts.

Thanks
Title: Re: HTML Reprompt Button With JS Error Checking
Post by: richard@AA on 01 May 2012 01:00:50 PM
I got the code I needed.....if someone does need it here it is

<fieldset class="clsFieldSet">
   <button type="button" name="Reprompt" id="Reprompt" onclick="RefreshErrorCheck();" style="font-size : 9 pt; font-face:arail" class="clsPromptButton" onmouseover="this.className = 'clsPromptButtonOver'" onmouseout="this.className = 'clsPromptButton'" onkeypress="return preventSubmitEvent(event);">Refresh</button>
</fieldset>

<script language="javascript">

           function RefreshErrorCheck()
           {
                      //these get the number of options in the value pompt
                      var DateOptionsLen = (document.formWarpRequest._oLstChoicesStartDateID.options.length - 1);
//CheckType is a hidden textbox prompt I have to tell if I'm coming into the page for the first time or not....
                      var CheckType = document.formWarpRequest._textEditBoxFirstLightID.value;

                      if (CheckType == 1)
                      {
                           var StartDateCount;
                           var EndDateCount;
                           var StartDateValue;
                           var EndDateValue;
 
                           //loop thru backwards - reused this code from something else and I could care less here if it's backwards or forward....
                           for ( StartDateCount = DateOptionsLen; StartDateCount >=0 ; StartDateCount--)
                           {
                                if (document.formWarpRequest._oLstChoicesStartDateID[StartDateCount].selected == true)
                                {
                                     //select that line
                                     StartDateValue = document.formWarpRequest._oLstChoicesStartDateID[StartDateCount].value;
                                     break;
                                }           
                           }

                           //loop thru backwards
                           for ( EndDateCount = DateOptionsLen; EndDateCount >=0 ; EndDateCount--)
                           {
                                if (document.formWarpRequest._oLstChoicesEndDateID[EndDateCount].selected == true)
                                {
                                     //select that line
                                     EndDateValue = document.formWarpRequest._oLstChoicesEndDateID[EndDateCount].value;
                                     break;
                                }           
                           }

                           if (StartDateValue > EndDateValue)
                           {
                                alert('End Date is prior to Start Date');
                           }
                           else
                           {
                                promptAction('Reprompt');
                           }
                      }
           }
</script>