显示前4个当前季度&之前的宿舍 [英] Show top 4 Current Quarter & prior Quarters

查看:65
本文介绍了显示前4个当前季度&之前的宿舍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在尝试使用javascript获取当前和上一季度。请建议一个可以获取当前和前几个季度的功能。 Belo是我的javascript函数,用于获取当前年度的当前季度。



Hi All,

I am trying to get the Current and Previous quarters using javascript. Please suggest a function which can fetch me current and previous quarters. Belo is my javascript function to get the current quarter for the current year.

function getQuarter(d) {
            var enterOnce = true;
            d = d || new Date();
            var m = Math.floor(d.getMonth() / 3) + 1; // gives you the current quarter.



            return m > 4 ? m - 5 : m;
        }





同样我也应该得到前几个季度





Likewise i should get the previous quarters also

function FillDropdownList() {
            var firstListItem = "<option value = '0'>select quarter</option>";
            var currentQuarter = getQuarter(new Date());
            var listOptions = "";
            for (var i = currentQuarter; i; i--) {
                listOptions += "<option value = '" + i + "'>Q" + i + " " + (new Date).getFullYear() + " list" + "</option>";
            }
            listOptions = firstListItem + listOptions;

            // to have short list of options which corresponds to the country
            // from the row we have to change temporary the column property
            $("select#drpQuarter").empty();
            setTimeout(function() { $("select#drpQuarter").html(listOptions); }, 200);
        }





现在我的输出就是这样:



选择季度

2014年第一季度清单



,而我希望输出为:





选择季度

2014年第一季度清单

2013年第4季度清单

2013年第3季度清单
2013年第二季度清单



我如何获得此类输出。



谢谢提前。



Now my output shows this way :

select quarter
Q1 2014 list

, whereas i want the output as:


select quarter
Q1 2014 list
Q4 2013 list
Q3 2013 list
Q2 2013 list

How can i get this type of output.

Thanks in advance.

推荐答案

(select#drpQuarter)。empty();
setTimeout(function(){
("select#drpQuarter").empty(); setTimeout(function() {


(select#drpQuarter)。html(listOptions);},200);
}
("select#drpQuarter").html(listOptions); }, 200); }





现在我的输出就是这样:



选择季度

2014年第一季度清单



,而我希望输出为:





选择季度

2014年第一季度清单

2013年第4季度清单

2013年第3季度清单
2013年第二季度清单



我如何获得此类输出。



谢谢提前。



Now my output shows this way :

select quarter
Q1 2014 list

, whereas i want the output as:


select quarter
Q1 2014 list
Q4 2013 list
Q3 2013 list
Q2 2013 list

How can i get this type of output.

Thanks in advance.


检查这个



http://stackoverflow.com/questions/9840512/get-dates-for-last-quarter-and-this-四分之一通过javascript / 9840971#9840971 [ ^ ]


这篇关于显示前4个当前季度&amp;之前的宿舍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆