English 中文(简体)
如何在 jquery 中创建用于以日、周和月等步骤的带距滑滑滑滑滑滑滑滑滑滑滑滑滑滑滑滑
原标题:how to create a range slider in jquery for steps as daily,weekly and monthly

我想创建一个范围滑动器, 该滑动器运行于下拉菜单 {每日, 每周和每月} 。

On selection of daily steps are changed to 7 and minDate chages to maxDate means todays date-7. On selection of weekly steps are changed to 4(7-7-7-7=30) and minDate chages to (maxDate)today date-30. on selection of monthly steps are changed to 12(12 months=365 days) and minDate chages to (maxDate)today date-365.

鼠标指针指向最大

var maxdate1 = new Date(),
    minDate1 = removeDays(new Date(), -7);
alert(minDate1);

$( "#slider" )
  .slider({range: true,
      step:  1,
      animate:true,
      value: maxDate1,
      values [minDate1, maxDate1],
      max: Math.floor((maxDate1.getTime() - minDate1.getTime()) / 86400000),

      slide: function(event, ui) {

        var date = new Date(minDate1.getTime());
        date.setDate(date.getDate() + ui.values[0]);

        $( #startDate ).val($.datepicker.formatDate( mm/dd/yy , date));
        $( #from ).val($.datepicker.formatDate( M d, yy , date));          

        date = new Date(minDate1.getTime());

        date.setDate(date.getDate() + ui.values[1]);

        $( #endDate ).val($.datepicker.formatDate( mm/dd/yy , date));
        $( #to ).val($.datepicker.formatDate( M d, yy , date));
      }
  });
问题回答

如果我理解正确的话, 您想要在滑动器初始化后更改滑动器的参数( 如步、 分钟、 最大等) 。 类似的东西应该有效 :

$( #dropdown ).change(function() {
    switch ($(this).val()) {
    case  daily :
        $( #slider ).slider( option ,  step , 1);
        break;
    case  weekly :
        $( #slider ).slider( option ,  step , 7);
        break;
    case  monthly :
        $( #slider ).slider( option ,  step , 30);
        break;
    }
});




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签