javascript - Click button to load set daterange using Datepicker instead of new Date(); -


I have a working range selection using the basic Jquery UI date range from the UI website.

HTML & lt; Button ID = "Week" & gt; Last week & lt; / Button & gt; & Lt; Br / & gt; & Lt; Label = "to" & gt; From & lt; / Labels & gt; & Lt; input type = "text" id = "to" name = "to" value "" & gt; & Lt; = "To" for label & gt; From & lt; / Labels & gt; & Lt; Input type = "text" id = "to" name = "to" value ""> Datasheet ({defaultDate: "+ 1w", Date format: 'MM D, or',

JQ

Number of minutes: 1, oncloses: function (selected) {$ ("# to"). Datapikar ("option", "minute date", selected date);}}); $ ("#to"). Datasheet ({defaultDate: "+ 1W", Date Format: 'MM D, or', Number of Forums: 1, Oncloses: Function (SelectedDate) {$ ("#from") .Datetime (" Option "," maximum date ", selected date);}});

I have to add a button to automatically select the last 7 days from the current date. I have used the new date (); The method to obtain a 'work' version (there is no date at the moment)

  $ ("#week"). Click (function () {var today = new date (); var lastweek = new date (new date). SetDate (new date) GetDate () - 7)); $ ("#from") .val (last), $ ("#to") .val (today);});   

However, I like to use the datepicker function to get the limit last week, and I can not figure out how to achieve it (if it is also possible) . The primary reason is that if a user chooses the "Previous Week" button, then selects a new date, I want to select the current date on the calendar widget.

I have this in a jsfiddle

After posting the boom boom boom Another related question was presented to me and I was able to use it as a basis for understanding:

  $ ("#week") .click (function () { var today = new date (); var from = new date (today.gate time); setate (from .get date () - 7); $ ("#s"). Date picker ("setdate" Today); $ ("#s"). Dadepiqr (from "setdate", to);});   

updated

Thanks for the Stackoverflow, always for me.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -