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

Sample JAVASCRIPT for Dateprompt

Started by Gnani, 14 Jul 2011 07:10:32 AM

Previous topic - Next topic

Gnani

Default select 1 year in Date prompt
<script> window.onLoad= subtractDay ()
function subtractDay ()
{
var dtToday = new Date();
var Yr = dtToday.getYear();
var lastdate = [Yr,12,31].join("-");
var firstdate = [Yr,01,01].join("-");
pickerControlp1.setValue(firstdate);
pickerControlp2.setValue(lastdate);
}
</script>


From-Jan1 same year, To-Today date
<script> window.onLoad= subtractDay ()
function subtractDay ()
{
var dtToday = new Date();
var Yr = dtToday.getYear();
var dt = dtToday.getDate();
var month = dtToday.getMonth()+1;
var lastdate = [Yr,month,dt].join("-");
var firstdate = [Yr,01,01].join("-");
pickerControlp1.setValue(firstdate);
pickerControlp2.setValue(lastdate);
}
</script>



previous month in date prompt
<script>
             window.onLoad= subtractDay ()

      function subtractDay ()
      {

                         var dtToday = new Date();
                         var month = dtToday.getMonth();
                         var year = dtToday.getYear();
                         var dt = 0;
                         var Yr = dtToday.getYear();

                          var m = [31,28,31,30,31,30,31,31,30,31,30,31];

            if (month != 0)
              {
                     dt = m[month-1];
                    
              }

            else
              {
                     if (year%4 != 0)
                         {
                                     dt = m[1]+1;
                                
                         }
                       else
                     {
                            if (year%100 == 0 && year%400 != 0)
                                {
                                     dt = m[1];
                                                                   }
                     }
              }

              if(month != 0)
                {
                         Yr = dtToday.getYear();
                     
                     
                   }
                   else
                   {
                                     Yr = year-1;
month = 12;dt = 31;
                                                                         month = 12;
                }
             
                   var lastdate = [Yr,month,dt].join("-");
                   var firstdate = [Yr,month,01].join("-");
                    

                         pickerControlp1.setValue(firstdate);
                         pickerControlp2.setValue(lastdate);
      }
</script>


To Select 1st Date of Month in Date Prompt.


<script>
             window.onLoad= subtractDay ()

      function subtractDay ()
      {

                         var dtToday = new Date();
                         var Yr = dtToday.getYear();
                         var month = dtToday.getMonth();
                         var mn = month+1;
          var firstdate = [Yr,mn,01].join("-");
                  
                         pickerControlp1.setValue(firstdate);
      }
</script>

Gnani

JAVASCRIPT for Passing values from date prompt (DateCalendar) to textbox prompt (DateText)

<script type = "text/javascript">

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

function checkRunPrompts()
{

var dtv = fw.txtDateDateCalendar.value;

var date1 = new Date(dtv);

var marray = new Array('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC');
fw.elements["_textEditBoxDateText"].value = date1.getDate() + "-" + (marray[date1.getMonth()]) + "-" + date1.getYear();

promptButtonFinish();

}

var ele = fw.elements;
var buttonName = "";
for (var d =0; d<ele.length;d++)
{
   var bName = ele[d].name;
   if((ele[d].type=='button')&&(bName.substring(0,6)=='finish'))
   {
      buttonName=ele[d].name;
      eval("fw.elements["+""+buttonName+""+"].onclick = checkRunPrompts");
   }

}

</script>