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

onChange Date Prompt Javascript

Started by kenrisen, 24 Jul 2012 01:03:14 AM

Previous topic - Next topic

kenrisen

I have a Date Prompt in the same page as in the Report.
When the user selects Date E.g 1st Jan 2012 , I want to populate an hidden prompt with 20120101 as value. I want this to happen only when the Date Changes and not when the Finish (prompt button) is hit

In Normal Javascript, we can add onChange event in the elements, I don't know how to add this for a Date Prompt.
Can we do that?Even i use .onchange, cognos never trigger the alert in the if statement.

here my simple syntax

<script type="text/javascript">

var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}

var theSpan = document.getElementById("A1");

var date =pickerControlp_date.m_oForm.value;
var len = date.length;
var year = date.substring(len-6,len-len);

var month = date.substring(5,7);


fW._textEditBoxp_text.value =month+year ;

theSpan.onchange = function() {
   
   alert(theSpan);
   
}

</script>

pricter

I think it would be much easier to try to change the format that the date prompt give you in your query rather to feed an second prompt in order to achieve that.

Do you have specific reason for not trying to manipulate the format of the date prompt in the query?

kenrisen

Hi Pricter,

thx for your suggestion but i can not do that because the data type in the table's field not DATE and the data very huge.
If I just use the data item from the fields (MonthYear, ex 012012) with select distinct function as a prompt, I need wait 3minutes for a prompt page.

So i think using the calender prompt will give better performance. the concept is every time user change the date value from date prompt i need get the value using a javascript, i succeed capture onchange event if i didn't use date prompt (ex, fW._oLstChoicesp_date.onchange). For Date prompt, I didn't know how to implement the onchange event.



kenrisen

Using the below script i can get the onchange function if the user type the date in the textbox, if the user choose from the calendar the onchange event will not be triggered.

does any one have any experience for this?

--------------------------------------------------------------------------------------------------
Javascript Syntax

<script type="text/javascript">

var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}

var theSpan = document.getElementById("A1");
var date =pickerControlp_date.m_oForm.value;
var len = date.length;
var year = date.substring(len-6,len-len);
var month = date.substring(5,7);

fW._textEditBoxp_text.value =month+year ;

fW.txtDatep_date.onchange = function() {
   alert("ok");
   var date =pickerControlp_date.m_oForm.value;
   var len = date.length;
   var year = date.substring(len-6,len-len);
   var month = date.substring(5,7);   

   fW._textEditBoxp_text.value =month+year
}

</script>

pricter

You can manipulate what the date prompt gives you for example the
data item [SalesDate] is an integer that reprensents the date as 20120101
If you filter the [SalesDate] with the following filter
[SALES_DATE]=
(
cast(substring(?Parameter1?,1,4),integer)*10000
+
cast(substring(?Parameter1?,6,2),integer)*100
+
cast(substring(?Parameter1?,9,2),integer)
)

You will manage to filter a date presented as integer with a date prompt

kenrisen

yes correct.. I will do like your suggestion using this syntax
var date =pickerControlp_date.m_oForm.value;
   var len = date.length;
   var year = date.substring(len-6,len-len);
   var month = date.substring(5,7);   

   fW._textEditBoxp_text.value =month+year

So i need get the onchange event implemented to catch the user selection from the date prompt

pricter

Maybe I was not so clear

I am suggesting not to use a text box.

But to use the filter that I have already written as filter in the query.

In this case you 
a) do not have to use a value prompt with distinct dates
b) use a date prompt
c) do not have to use javascript

Is now more clear my suggestion?

kenrisen

WOW...cooollllll....Thank you so much Pricter...^^