Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I did something similar, but with radio buttons. Hope it helps:</p> <pre><code> function reset_last_checkboxes() { $("#export_last_month").attr("checked", false); $("#export_3_last_months").attr("checked", false); $("#export_last_year").attr("checked", false); } var date_format = "DD, d MM, yy"; $("#id_from_date").attr("readonly", "readonly"); $("#id_till_date").attr("readonly", "readonly"); $("#id_from_date").datepicker(); $("#id_till_date").datepicker(); $( "#id_from_date" ).change(function() { $( "#id_from_date" ).datepicker( "option", "dateFormat", date_format ); }); $( "#id_till_date" ).change(function() { $( "#id_till_date" ).datepicker( "option", "dateFormat", date_format ); }); $( "#id_from_date" ).click(function() { reset_last_checkboxes(); }); $( "#id_till_date" ).click(function() { reset_last_checkboxes(); }); $("#id_till_date").val(format_date(new Date(now))); $("#export_last_month").click(function(){ var dt = new Date(now); $("#id_till_date").val(format_date(dt)); $("#id_from_date").val(format_date(prevMonth(dt))); }); $("#export_3_last_months").click(function(){ var dt = new Date(now); $("#id_till_date").val(format_date(dt)); $("#id_from_date").val(format_date(prevMonth(prevMonth(prevMonth(dt))))); }); $("#export_last_year").click(function(){ var dt = new Date(now); $("#id_till_date").val(format_date(dt)); for (var i=0;i&lt;12;i++) { dt = prevMonth(dt); } $("#id_from_date").val(format_date(dt)); }); </code></pre> <p>You can always replace my radio buttons with drop down menu and write this code better than me :)</p> <p>By the way, prevMonth I calculate this way:</p> <pre><code>function prevMonth(dt){ var thisMonth = dt.getMonth(); dt.setMonth(thisMonth-1); if(dt.getMonth() != thisMonth-1 &amp;&amp; (dt.getMonth() != 11 || (thisMonth == 11 &amp;&amp; dt.getDate() == 1))) dt.setDate(0); return dt; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload