1

I am using this timer http://tutorialzine.com/2011/12/countdown-jquery/

I can set the target value on script.js by

var note = $('#note'),
ts = new Date(2013, 05, 25),
newYear = true;

I want to set the value of ts by taking a value from datepicker. date picker has an option which is onSelect : hope we can define function here.

I want to define something like, when a user select a date from datepicker it will parse the date and put to the variable

var note = $('#note'),
ts = new Date(year, month, day),
newYear = true;

Thanks

update: got one solution by writing the code http://pastebin.com/NHRuJ5mL

4

3 回答 3

0

如您所料,您可以使用以下onSelect功能:

选择日期选择器时调用。该函数接收选定的日期作为文本和 datepicker 实例作为参数。这指的是关联的输入字段。

并在输入字段中获取所选值,例如:

$("#TxtStrtDate").datepicker({
    onSelect: function( selectedDate ) {
        alert(selectedDate)
    }
});

使用新值,您可以将其拆分为 DD、MM、YYYY,并且可以重新启动倒计时脚本。

这是一个小小提琴:http: //jsfiddle.net/PQfDc/6/

于 2013-06-04T17:59:25.097 回答
0

Given that you are using JQuery this should be pretty simple. You can do something like the following

 $('#dtTest').change(function(event) {
    ts = new Date($(this).val());
    newYear = true;
 });
于 2013-06-04T18:05:21.920 回答
0
$("#datepicker").datepicker({
   onSelect: function(dateText, inst) { 
      var dateAsString = dateText; //the first parameter of this function
      var dateAsObject = $(this).datepicker( 'getDate' ); //the getDate method
   }
});
于 2013-06-04T17:55:39.033 回答