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

Javascript for date prompt

Started by niahanth, 23 Jan 2016 04:56:07 PM

Previous topic - Next topic

niahanth

Hi,
I have two date prompts Begin Date and End Date. Can anyone help me with the javascript code when while running the report if we enter begin date > end date it should display a message like "The dates selected ate invalid"

Thanks

bdbits

You want this on the prompt page? Do you have any javascript skills?

Or on the report itself, you could use conditional rendering. Have two objects on the report, one could be a text item with your message and the other your report data container (list, crosstab, etc.). The date check will render the text item if true, and the report data container if false.

afzaki7

#2

hey my friend
here is the scenario



1-add table contain 1 column and 3 rows
2-in the first two rows add two Dateprompt  name the first DP1 and the second DP2
3 in the third row add 2 HTML element
4- in the first HTML element add this script
Quote
<script>
    function myfunction() {
        var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
        if (!fW || fW == undefined) {
            fW = (formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_);
        }
        var Date1 = new Date(fW.txtDateDP1.value);
        var Date2 = new Date(fW.txtDateDP2.value);

        var day1 = Date1.getDay();
        var month1 = Date1.getMonth(); //months from 1-12
        var year1 = Date1.getFullYear();

        var day2 = Date2.getDay();
        var month2 = Date2.getMonth();
        var year2 = Date2.getFullYear();

        if (year2 > year1) {
            alert('no way')
        } else if (year2 == year1) {
            if (month2 > month1) {
                alert('no way');
            } else if (month2 == month1) {
                if (day2 > day1) {
                    alert('no way');
                } else {
                    alert('ok')
                }

            } else {
                alert('ok');
            }
        } else {
            alert('ok')
        }
    }
</script>

5- in the second HTML element add this script


Quote<button type="button" onclick='myfunction();' > Click Me!</button>

now you can replace the alert message of whatever you want
no way = failed ----> alert the user of what you want
ok = pass -----> call finish function ex:promptButtonFinish();

Thanks
" إِذَا مَاتَ ابْنُ آدَمَ انْقَطَعَ عَمَلُهُ إِلا مِنْ ثَلاثٍ : مِنْ صَدَقَةٍ جَارِيَةٍ ، أَوْ عِلْمٍ يُنْتَفَعُ بِهِ ، أَوْ وَلَدٍ صَالِحٍ يَدْعُو لَهُ "